(8)若有如下定义,double a[100];则a数组元素的下标上限是【8】 。
(9)下面程序的输出结果【9】 。
main ()
{enum team {y1=4,y2,y3};
printf ("%d",y3);}
(11)若有以下程序段:
int c1=1,c2=2,c3;
c3=1.0/c2*c1;
则执行后,c3中的值是【11】 。
(12) 若有以下定义:
char a;int b;
float c; double d;
则表达式a*b+d-c值的类型为【12】 。
(13)设有代码“static int a[3][4]={{1}, {2}, {3}};”,则a[1][1]和a[2][1]的值为【13】 。
(14)以下函数用来在w数组中插入x。n所指向的存储单元中存放w数组中字符个数。数组w中的字符已按从小到大的顺序排列,插入后数组w中的字符仍有序。请填空。
void fun(char *w, char x, int *n)
{ int i, p;
p=0;
w[*n]= x;
while(x > w[p])p++;
for(i=*n; i>p; i--)w[i]=【14】;
w[p]=x;
++*n;}
(15)设int a, b=10;执行a=b<<2+1;后a的值是【15】 。
(16)以下程序的输出结果是【16】。
main()
{ int x=100, a=10, b=20, ok1=5, ok2=0;
if(aelse if(ok2)x=10;
else x=-1;
printf("%d\n", x);}
(17)以下程序的输出结果是【17】。
main()
{ int y=9;
for(; y>0; y--)
if (y%3==0)
{printf("%d", --y); continue;}
}
(18)以下函数的功能是【18】。
float av(a, n)
float a[];
int n;
{ int i; float s;
for(i=0, s=0; ireturn s/n;}
(19)以下程序的输出结果是【19】。
#define PR(ar)printf("%d,",ar)
main()
{ int j, a[]={1, 3, 5, 7, 9, 11, 15}, *p=a+5;
for(j=3; j; j--)
switch(j)
{ case 1:
case 2: PR(*p++); break;
case 3:PR(*(--p));
}
printf("\n");
}
(20)以下程序的功能是:处理由学号和成绩组成的学生记录,N名学生的数据已在主函数中放入结构体数组s中,它的功能是:把分数最高的学生数据放在h所指的数组中注意:分数高的学生可能不只一个,函数返回分数最高学生的人数。请填空。
#include
#define N 16
typedef struct
{char num[10];
int s ;
} STREC;
int fun (STREC *a, STREC *b)
{int i,j=0,max=a[0].s;
for(i=0;iif(maxfor(i=0;iif(【20】)b[j++]=a[i];
return j;
}
main ()
{STREC s[N]={{ "GA005",85},{"GA003",76},{"GA002",69},{"GA004",85},
{"GA001",91},{"GA007",72},{"GA008",64},{"GA006",87},
{"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91},
{"GA011",66},{"GA017",64},{"GA018",64},{"GA016",72}
};
STREC h[N];
int i, n;FILE *out;
n=fun(s,h);
printf("The %d highest score :\n",n);
for (i=0; iprintf("%s M\n ",h[i].num,h[i].s);
printf("\n");
out=fopen("out15.dat", "w");
fprintf(out, "%d\n",n);
for(i=0; ifprintf(out, "M\n ",h[i].s);
fclose(out);
}
07年4月计算机等级考试二级C语言考前密卷答案(5)