第1页是真题,第2页是简要的解答提示,第3页是解题分析和答案。强烈建议先尝试自己完成,或者借助第2页的解答提示来完成,实在不明白再看答案。
第6~13题
6. 以下程序运行时输出到屏幕的结果为 (6)
1 2 3 4 5 6 7 8 9 | #include <stdio.h> #define L 10 #define C L+L void main() { int Area; Area=C*L; printf("%d\n",Area); } |
7. 以下程序运行时输出到屏幕的结果是 (7)
1 2 3 4 5 6 7 8 9 | #include <stdio.h> enum {A,B,C=4} i; void main() { int k=0; for(i=B; i<C; i++) k++; printf("%d",k); } |
8. 以下程序运行时输出到屏幕的结果是 (8)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <stdio.h> void fun(int a) { printf("%d ", a%10); if(a=a/10!=0) fun(a); } void main() { int a=-13; if(a<0) { printf("-"); a=-a; } fun(a); } |
9. 以下程序运行时若输入“2010 10”,则输出到屏幕的结果的第一行是 (9),第三行是 (10)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <stdio.h> char *fun(int n) { static char s[20]; static int c; char t[10]= {0}, i=0,j,k; while(n>0) t[i++]=n%10+'0',n=n/10; puts(t); for(j=0; j<i/2; j++) k=t[j], t[j]=t[i-1-j], t[i-1-j]=k; strcat(s,t); if(c<1) { strcat(s, "/"); c++; } else strcat(s, "\0"); return s; } void main() { int i,m; char *p; for(i=0; i<2; i++) { scanf("%d", &m); p=fun(m); } puts(p); } |
10. 以下程序运行时输出到屏幕的结果是第一行是 (11),第二行是 (12)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <stdio.h> #define M 3 #define N 4 void fun(int a[M][N]) { int i,j,p; for(i=0; i<M; i++) { p=0; for(j=1; j<N; j++) if(a[i][p]>a[i][j]) p=j; printf("%d\n ", a[i][p]); } } void main() { int a[M][N]= {{-1,5,7,4},{5,2,4,3},{8,2,3,0}}; fun(a); } |
11. 以下程序运行时输出到屏幕的结果中第一行是 (13),第二行是 (14)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <stdio.h> int f(int *x, int *y, int z) { *x=*y ; *y=z; z=*x; return z; } void main() { int a=1,b=2,c=3,d; d=f(&a,&b,c); printf("%2d%2d\n %2d%2d\n ",a,b,c,d); } |
12. 以下程序运行时输出到屏幕的结果中第一行是 (15),第二行是 (16)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <stdio.h> struct grade { int id; char level[3]; int score[3]; }; char fun(struct grade *t) { int i,count=0,total=0; for(i=0; i<3; i++) { if(t->level[i]== 'A') count++; total=total+t->score[i]; } total=total+count; if(count==3) total++; return (total>380? 'Y': 'N'); } void main() { int i; struct grade stu[3]= { {106, "AAA",130,132,115}, {107, "BAB",113,125,104}, {109, "AAB",128,135,114}}; for(i=0; i<2; i++) printf("\%d %c\n",stu[i].id,fun(&stu[i])); } |
13. 以下程序运行时输出到屏幕的结果第一行是 (17),第二行是 (18)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <stdio.h> int fun(int a[], int *p) { int i,n; n=*p; p=&a[n-1]; for(i=n-2; i>=0; i--) if(a[i]>*p) p=&a[i]; return *p; } void main() { int a[5]= {18,2,16,3,6},x=5,y; y=fun(a,&x); printf("%d\n",x); printf("%d\n",y); } |