填空题下面程序的运行结果是{{U}} 【17】 {{/U}}。
typedef union student
{ char name[10];
long sno;
char sex;
float score[4];
} STU;
main()
{ STU a[5];
printf("%d/n",sizeof(a));
}
填空题有以下程序: #include<stdio.h> fun(int x) if(x/2>0)fun(x/B); printf("%d",x); main() fun(6);printf("/n"); 程序运行后的输出结果是______。
填空题请补充main函数,该函数的功能是:输出一个N×N矩阵,要求非对角线上的元素赋值为0,对角线元素赋值为1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#define N 10
main ( )
{
int bb[N] [N];
int i, j,n;
clrscr ();
printf (" /nInput n:/n");
scanf ("%d",
for (i=0; i<n; i++)
for (j=0; j<n; j++)
{
{{U}} 【1】 {{/U}};
if (i==j)
bb[i] [j]={{U}} 【2】 {{/U}};
if ({{U}} 【3】 {{/U}})
bb[i] [j]=1;
}
printf(" /n***** the result ***** /n");
for (i=0; i<n; i++)
{
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j] );
}
}
填空题下面程序的执行结果是 【9】 。 main() int a=5,b=4,c=9; printf("###%d",(a<C) ?c*b:a*B) ;
填空题以下程序运行后输入:3,abcde,则输出结果是{{U}} 【17】 {{/U}} #include <string.h> move(char *str, int n) { char temp; int i; temp=str[n-1]; for(i=n-1;i>0;i--) str[i]=str[i-1]; str[0]=temp; } main( ) { char s[50]; int n, i, z; scanf("%d,%s", z=strlen(s); for(i=1; i<=n; i++) move(s, z); printf("%s/n",s); }
填空题下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意
:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<conio.h>
#include<stdio.h>
/********found********/
double fun(char *s,char *t)
{
int s1=0,t1=0;
char *ss,*tt;
ss=s;
tt=t;
while(*ss)
{
s1++;
/********found********/
(*ss)++;
}
while(*tt)
{
t1++;
/********found********/
(*tt)++;
}
if(t1>s1)
return t;
else.
return s;
}
main()
{
char a[80],b[80];
printf("/nEnter a string:");
gets(a);
printf("/nEnter a string again:");
gets(b);
printf("/nThe longer is:/n/n%s/n",fun (a,b));
}
填空题若有如下程序: main() int x=5,y,*t;t=&x; y=++(* t); printf("%d,%d",x,y); 则程序执行后的x值为 【11】 ,y的值为 【12】 。
填空题下列程序的输出结果是______。 main() int i; for(i=1;i+1;i++) if(i>4) printf("%d/n",i); break; printf("%d/n",i++);
填空题下列给定程序中函数fun的功能是:将m(1≤m≤10)个字符串连接起来,组成一个新串,放入pt所指存储区中。例如,把三个串“abc”、“CD”、“EF”连接起来,结果是“abcCDEF”。
请改正程序中的错误,使它能得出正确的结果。
注意
:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
void fun (char str[][10],int re,char *pt)
{
/********found********/
Int k,q,i;
for(k=0;k<m;k++)
{q=strlen(str[k]);
for(i=0;i<q;i++)
/********found********/
pt[i]=str[k,i];
pt+=q;
pt[0]=0;
}
}
main()
{int m,h;
char s[10][10],p[120];
printf("Please enter m:");
scan("%d", gets(s[0]);
printf("Please enter %d string:",m);
for(h=0;h<m;h++)gets(s[h]);
fun(s,m,p);
printf("The result is:%s",p);
}
填空题在对文件进行操作的过程中,若要求文件的位置指针重新指向文件的开头,应当调用的函数是{{U}} 【16】 {{/U}}函数。
填空题以下程序运行后的输出结果是{{U}} 【18】 {{/U}}。
#include <stdio.h>
main()
{ int i,m=0,n=0,k=0;
for(i=9;i<=11;i++)
switch(i/10)
{ case 0: m++;n++;break;
case 10: n++;break;
default: k++;n++;
}
printf("%d%d%d/n",m,n,k);
}
填空题给定程序中函数fun的功能是:从N个字符串中找出最长的那个串,并将其地址作为函数值返回。
各字符串在主函数中输入,并放入一个字符串数组中。所找到的最长字符串在主函数中输出。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
给定源程序:
#include<stdio.h>
#include<string.h>
#define N 5
#define M 81
/**********found**********/
fun(char(*sq)[M])
{int i;char*sp;
sp=sq[0];
for(i=0;i<N;i++)
if(strlen(sp)<strlen(sq[i]))
sp=sq[i];
/**********found**********/
return sq;
}
main()
{char str[N][M],*longest;int i;
printf("Enter%d lines:/n",N);
for(i=0;i<N;i++)gets(str[i]);
printf("/nThe N string:/n",N);
for(i=0;i<N;i++)puts(str[i]);
longest=fun(str);
printf("/nThe longest string:/n");puts(longest);
}
填空题53. 下述函数统计—个字符串中的单词个数,单词是指处在空格之间的字符序列,请填空。int word(char*s) int num=0,flag=0;while(*s) if({{U}} {{/U}}='') flag=0; else if({{U}} {{/U}})flag=1;num++return{{U}} {{/U}};
填空题已知字符'A'的ASCII码值为65,以下语句的输出结果是 【16】 。 char ch='B'; printf("%c%d/n",ch,ch);
填空题数组xx[N]保存着一组4位无符号整数,其元素的个数通过变量num传入函数fun()。请补充函数fun(),该函数的功能是:从数组xx中找出个位和百位的数字相等的所有无符号整数,结果保存在数组yy中,其个数由函数fun()返回。
例如:当xx[8]={1111,2413,2321,2222,4245,3333,1414, 5335}时,bb[6]={1111,2321,2222,4245,3333,1414)。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#include<conio. h>
#define N 1000
int fun (int xx [], int bb [], int num)
{
int i, n=0;
int g,b;
for (i=0; i<num; i++)
{
g={{U}} 【1】 {{/U}};
b=xx [i]/100%10;
if (g==b)
{{U}}【2】 {{/U}}
}
return{{U}} 【3】 {{/U}};
}
main()
{
int xx [8] ={1111,2413, 2321, 2222, 4245,
3333,1414,5335 };
int yy[N];
int num=0, n=0, i=0;
num=8;
clrscr ();
printf ("*****original data ******/n ");
for (i=0; i<num; i++)
printf ("%u ",xx[i]);
printf ("/n/n/n");
n=fun (xx, yy, num);
printf ("/n yy= ");
for (i=0; i<n; i++)
printf ("%u ", yy [i]);
}
填空题下列给定程序中函数fun的功能是:用递归算法计算斐波拉契数列中第n项的值。从第1项起,斐波拉契数列为:1,1,2,3,5.8,13,21,… 例如,若给n输入7,则该项的斐波拉契数值为13。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构! 试题程序: #include<stdio.h> long fun(int g) /*********found*********/ switch(g); case 0:return 0; /*********found*********/ case 1;case 2:return 1; return(fun(g-1)+fun(g-2)); void main() long fib;int n; printf("Input n:"); scanf("%d",&n); printf("n=%d/n",n); fib=fun(n); printf("fib=%d/n/n",fib);
填空题以下程序的输出结果是{{U}} 【9】 {{/U}}。
#include <stdio.h>
void fun()
{ static int a=0;
a + =2;
printf("%d",a);
}
main()
{ int cc;
for(cc = 1;cc < 4; cc++) fun();
printf("/n");
}
填空题以下程序运行后的输出结果是 【13】 。 # include<string.h> void fun(char *s,int p,int k) int i; for(i=p;i<k-1;i++)s[i]=s[i+2]; main() char s[]="abcdefg"; fun(s,3,strlen(s));puts(s);
填空题若输入5、9,以下程序的运行结果为______。main() int a,b,*pt1,*pt2; printf("input a,b:"); scanf("%d%d",&a,&b); pt1=&a; pt2=&b; if(a<b) swap(pt1,pt2); printf("/n%d,%d/n",*pt1,*pt2);swap(p1,p2)int *p1,*p2; int *p; p=p1; p1=p2; p2=p;
填空题某微型机的运算速度为2MIPS,则该微型机每秒执行【 】条指令。
