B.Beijing,7
C.ChinaBeijing,12 D.BeijingChina,12
14.设typedef int ARRAY[10];,与语句ARRAY a,b;等价的是
A.int a,b; B.int a,b[10];
C.int a[10],b; D.int a[10],b[10];
15.表示“回车”的转义字符是
A.'\r' B.'\t'
C.'\o' D.'\n'
非选择题部分
注意事项:
用黑色字迹的签字笔或钢笔将答案写在答题纸上,不能答在试题卷上。
二、填空题(本大题共10小题,每小题2分,共20分)
16.执行语句printf ("%d",3^5);后的输出结果是__________。
17.在C语言的文件使用中,EOF的值是__________。
18.设float x,y,z;,
的C语言算术表达式是__________。
19.运算符+=,!和&&中优先级最高的是__________。
20.设int a,b;,与a*=5-b;等价的赋值语句是__________。
21.系统函数sqrt()应使用的文件包含命令是__________。
22.在C语言中,表示逻辑“假”的值是__________。
23.设char ch='A';,执行语句printf("%c,%d",ch+32,ch);后的输出结果是__________。
24.设int n=123;,执行语句printf("%d",n/10%10);后的输出结果是__________。
25.在C语言中,将圆周率(PI=3.1415926)定义为常量的宏定义命令是__________。
三、程序分析题(本大题共4小题,每小题4分,共16分)
阅读下列程序,将输出结果写到答题纸上。
26.#includc<stdio.h>
void main()
{ char op;
int a=10,b=20;
for(op='a';op<='d';op+=2)
switch(op)
{
case 'a':printf("a+b=%d\n",a+b);break;
case 'b':printf("a-b=%d\n",a-b);break;
case 'c':printf("a*b=%d\n",a*b);break;
case 'd':printf("a/b=%d\n",a/b);break;
}
}
27.#include<stdio.h>
void sub (int x, int y, int *z)
{ *z=x+y; }
void main( )
{ int a=2,b=5,c;
sub(a,b,&c);
printf("%d, %d, %d\n", a, b, c);
}
28.#include<stdio.h>
int x=l; /* 全局变量 */
void fx(int p)
{ x=p+x; p++; }
void main( )
{
inta=3;
fx(a);x++;
printf("%d, %d\n", a, x);
}
29.#include<stdio.h>
int power(int n) /* 递归函数 */
{
if(n==0)return 1;
else return 2*power(n-1);
}
void main( )
{ printf("%d\n", power(5)); }
四、程序填充题(本大题共3小题,每小题6分,共18分)
请将下列程序横线处缺少的部分补上,使其能正确运行。
30.计算1!+2!+3!+4!+5!的值并输出。
#include<stdio.h>
int f(int a)
{
static int c=1;
c=c*a;
return( ① ); /* 第一空 */
}
void main()
{
int i, k;
k=-l;
for(i=2;i<=5;i++)k+= ② ; /* 第二空 */
printf(" ③ \n",k); /* 第三空 */
}
31.设有30名学生,由键盘分别输入每个学生的姓名和两门课成绩,计算每个学生的总分,并输出总分最高者的姓名和总分。
#include<stdio.h>
#define N 30
struct st
{
char name[20];
float s1,s2,total;
};
void main()
{
struct st s[N];
int i,k;
float max;
for(i=0;i<N;i++)
{
scanf(%s%f%f", s[i].name, &s[i].s1,&s[i].s2);
s[i].total= ① ; /* 第一空 */
}
max= ② ; /* 第二空 */
for(i=1,k=-0;i<N;i++)
if(s[i].total>max)
{ max=s[i].total; ③ ;} /* 第三空 */
pfintf("%s,%f\n", s[k].name, max);
}
32.从键盘输入5个字符串,将其写到文本文件fs.txt中。
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE*fp;
char str[5][10];
int i;
for(i=0;i<5;i++)gets(str[i]); /* 输入字符串 */
if((fp=fopen("fs.txt", ① )==NULL) /* 第一空 */
{ printf("Can’t open file!\n");exit(0); }
for(i=0;i<5;i++) /* 写入文件 */
{
fputs( ② ,fp); /* 第二空 *