A)1313 B)2234 C)3234 D)1234 (33)有以下程序 #include
int f(int t[],int n); main()
{int a[4]={1,2,3,4},s;
s=f(a,4);printf(“%d\\n”,s);} int f(int t[],int n)
{if (n>0)return t[n-1]+f(t,n-1); else return 0;} 程序运行后的输出结果是
A)4 B)10 C)14 D)6 (34)有以下程序 #include
{static int x=1; x*=2;return x; }
main()
{int i,s=1;
for(i=1;i<=2;i++) s=fun();
printf(“%d\\n”,s); }
程序运行后的输出结果是
A)0 B)1 C)4 D)8 (35)有以下程序 #include
{int a=2,b=3,c=5,d; d=SUB(a+b)*c;
printf(“%d\\n”,d); }
程序运行后的输山结果是
A)0 B)-12 C)-20 D)10 (36)设有定义: struct complex
{int real,unreal;} data1={1,8},data2; 则以下赋值语句中错误的是
A)data2=data1; B)data2=(2,6);
C)data2.real=data1.real; D)data2.real=data1.unreal; (37)有以下程序 #include
struct A
{int a;char b[10];double c;}; void f(struct At); main()
{struct Aa={1001,“ZhangDa”,1098.0};f(a); printf(“%d,%s,%6.1f\\n”,a.a,a.b,a.c);} void f(struct At)
{t.a=1002;strcpy(t.b,“ChangRong”);t.c=1202.0;} 输出结果是
A)1001,ZhangDa,1098.0 B)1002,ChangRong,1202.0 C)1001,ChangRong,10980 D)1002,ZhangDa,1202.0 (38)有以下定义和语句 struct workers
{int num;char name[20];char c; struct
{int day;int month;int year;}s };
struct workers w,*pw; pw=&w;
能给w中year成员赋1980的语句是
A)?pw.year=1980; B)w.year=1980; C)pw->year=1980; D)w.s.year=1980; (39)有以下程序 #include
{int a=2,b=a,c=2;
printf(“%d\\n”,a/b&c); }
程序运行后的输出结果是
A)0 B)1 C)2 D)3 (40)有以下程序 #include
{FILE *fp;char str[10]; fp=open(“myfile.dat”,“w”); fputs(“abc”,pf);close(pf); fp=open(“myfile.dat”,“a+”); fprintf(pf,“%d”,28); rewind(pf);
fscanf(pf,“%s”,str);puts(str); close(pf); }
程序运行后的输出结果是
A)abc B)28c
C)abc28 D)因类型不一致而出错 二、填空题(每空2分,共30分)
请将每空的正确答案写在答题卡【1】~【15】序号的横线上,答在试卷上不得分。 (1)一个队列的初始状态为空。现将元素A,B,C,D,E,F,5,4,3,2,1依次入队,然后再依次
退队,则元素退队的顺序为 【1】 。
(2)设某循环队列的容量为50,如果头指针front=45(指向队头元素的前一位置),尾指针
rear=10(指向队尾元素),则该循环队列中共有 【2】 个元素。 (3)设二叉树如下:
A B C D F E G H
对该二叉树进行后序遍历的结果为 【3】 。
(4)软件是 【4】 数据和文档的集合。
(5)有一个学生选课的关系,其中学生的关系模式为:学生(学号,姓名,班级,年龄),课程的
关系模式为:课程(课号,课程名,学时),其中两个关系模式的键分别是学号和课号,则 关系模式选课可定义为:选课(学号, 【5】 ,成绩)。
(6)设x为int型变量,请写出一个关系表达式 【6】 ,用以判断x同时为3和7的倍数时,
关系表达式的值为真。 (7)有以下程序 #include
{int a=1,b=2,c=3,d=0; if(a==1) if(b!=2) if(c==3) d=1; else d=2;
else if(c!=3) d=3; else d=4; else d=5;
printf(“%d\\n”,d);
}
程序远行后的输出结果是 【7】 。 (8)有以下程序 #include
scanf(“%d%d”,&m,&n); while(m!=n) {while(m>n) m=m-n; while(m } 程序运行后,当输入14 63<回车>时,输出结果是 (9)有以下程序 #include main() {int i,j,a[][3]={1,2,3,4,5,6,7,8,9}; for(i=1;i<3;i++) for(j=1;j<3;i++) printf(“%d”,a[i][j]); printf(“\\n”); } 程序运行后的输出结果是 【9】 (10)有以下程序 #include main() {int a[]={1,2,3,4,5,6},*k[3],i=0; while(i<3) {k[i]=&a[2*i]; printf(“%d”,*k[i]); i++; } } 程序运行后的输出结果是 【10】 。 (11)有以下程序 #include {int a[3][3]={{1,2,3},{4,5,6},{7,8,9}}; int b[3]={0},i; for(i=1;i<3;i++) b[i]=a[i][2]+a[2][i]; for(i=1;i<3;i++)printf(“%d”,b[i]); printf(“\\n”); } 程序运行后的输出结果是 【11】 。 。【8】 (12)有以下程序 #include for(i=n-1;i>0;i--) str[i]=str[i-1];str[0]=temp; } main() {char s[50];scanf(“%s”,s);fun(s);printf(“%s\\n”,s);} 程序运行后输入:abcdef<回车>,则输出结果是 【12】 (13)以下程序的功能是:将值为三位正整数的变量x中的数值按照个位、十位、百位的顺序拆分并输出。请填空。 #include {int x=256; printf(“%d-%d-%d\\n”,【13】,x/10,x/100); } (14)以下程序用以删除字符串中所有的空格,请填空。 #include main() {char[100]={“Our teacher teach c language!”};int i,j; for(i=j=0;s[i]!=‘\\0’;i++) if(s[i]!=‘ ’) {s[j]=s[i];j++;} s[j]=【14】; printf(“%s\\n”,s); } (15)以下程序的功能是:借助指针变量找出数组元素中的最大值及其元素的下标值。请 填空。 #include {int a[10],*p,*s; for(p=a;p-a<10;p++) scanf(“%d”,p); for(p=a,s=a;p-a<10;p++) if(*p>*s) s=【15】; printf(“index=%d\\n”s-a); } 参考答案: 一、选择题: 1.C 2.D 3.B 4.A 5.C 6.B 7.A 8.D 9.C 10.A 11.B 12.A 13.D 14.C 15.C 16.D 17.A 18.B 19.C 20.A 21.D 22.D 23.A 24.B 25.D 26.A 27.D 28.B 29.C 30.C 31.A 32.C 33.B 34.C 35.B 36.B 37.A 38.D 39.A 40.C