2007年9月计算机等级考试二级C语言模拟试题二及答案

出处:Examlink 作者:无风浪 日期:2007年08月30日 11时08分
          

6.以下程序的功能是从健盘输入若干学生的成绩,并输出最高成绩和最低成绩,当输入负数时结束。请填空。
main ()
{ float x,amax,amin;
scanf ("%f",&x);
amax=x;
amin=x;
while ( 【6】 )
{ if (x>amax)
amax=x;
else
if 【7】
amin=x;
else scanf ("%f",&x);
}
printf ("\n amax=%f\n amin=%f\n",amax,amin);
}  

 7.设在主函数中有以下定义和函数调用语句,且fun函数为void类型;请写出fun函数的首部 【8】 。要求形参名为b。
main()
{ double s[10][22];
int n; ┆

fun(s);

}

8.下列程序的功能是输入一个整数,判断是否是素数,若为素数输出1,否则输出0,请填空。
main()
{ int i, x, y=1;
scanf("%d", &x);
for(i=2; i<=x/2; i++)
if 【9】 { y=0; break;}
printf("%d\n", y);

 9.下面程序的功能是将一个字符串str的内容颠倒过来,请填空。
#include
main()
{ int i,j, 【10】 ;char str[]={"1234567"};
for(i=0,j=strlen(str) 【11】 ;i { k=str[i];str[i]=str[j];str[j]=k;}
printf("%s\n",str);
}
10.以下程序可把输入的十进制数以十六进制数的形式输出,请填空。
main()
{ char b[17]={"0123456789ABCDEF"};
int c[64],d,i=0,base=16;
long n;
printf("Enter a number:\n");scanf("%ld",&n);
do{c[i]= 【12】 ;i++;n=n/base;}
while(n!=0);
printf("Transmite new base:\n");
for(--i;i>=0;--i)
{d=c[i];printf("%c",b 【13】 );}
printf("\n");
}

参考答案:

选择题: 
1-10  B A B D D D D A B C
11-20  D D A C C D B A C D
21-30  C D B D B B A C B C
31-40  C D C C A   
       
填 空 题:
1-5   存储结构 继承 内聚 一对多||1∶N 概念设计阶段
6-10  x>0 a  void fun(double b[][22])||void fun(double b[10][22]) (x%i==0) k -1 n%base [d]
11-12  6354 -> 

最后更新时间:2008-05-28 12:13:56
文章评论
共有 0 位网友发表了评论
用户名: 新注册) 密码: 匿名评论 [查看所有评论]

评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
您可以用以下几种方式找到此文章

考试全流程