![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
2019年春江苏省计算机二级C语言真题 |
1(单选题): 若有声明“int a=3,b=4,c=5;”,则执行语句“a>b?a--:(b>c?b++:(c/=2)); printf("%d\n",a+b+c);”时输出_____9_____。 2 (填空题 <3空> ) : 以下程序运行时输出结果中第一行是3 ,第二行是 5 ,第三行是4 。 #include typedef struct node { int value; struct node *next; } NODE; void Max(NODE *head) { NODE *p,*first,*second; first=second=NULL; p=head; while(p!=NULL) { if(first==NULL||p->value>=first->value) { second=first; first=p; } else if(second==NULL||p->value>=second->value) second=p; p=p->next; } printf("%d\n%d", first->value, second->value); } int main( ) { NODE a[]={{3,&a[1]},{1,&a[2]},{5,&a[3]},{4,NULL}},*head=&a[0]; printf("%d\n", head->value); Max(head); return 0; } 3(单选题): 若有声明“char s1[80]="good ",s2[80]="luck ",s3[80]="to you";”,则执行语句 “strcpy(s1+5,strcat(s2,s3)); printf("%s",s1);”时输出____ good luck to you ______。 4 (填空题 <2空> ) : 以下程序运行时输出结果中第一行是22,第二行是11。 #include void series(int n) { while(n!=1) { if(n%2!=0) n=3*n+1; else while(n%2==0) n/=2; printf("%d\n",n); } } int main( ) { series(7); return 0; } 5 (填空题 <2空> ) : 以下程序运行时输出结果中第一行是0,第二行是4。 # include int f(int x,int y) { int t,i,M=23; if(y==1) return 0; for(i=t=1;i { t=t*x%M; if(t==y) return i; } printf("没有结果\n"); return 0; } int main( ) { printf("%d\n%d",f(3,1),f(4,3)); return 0; } 6(单选题): 以下声明中正确的是__________。 8 (填空题 <3空> ) : 以下程序运行时输出结果中第一行是1,第二行是1,第三行是3。 #include void Pascal(int a[],int n) { int i,j; for(a[0]=1,i=1;i<=n;i++) a[i]=0; for(i=1;i<=n;i++) for(j=i;j>0;j--) a[j]+=a[j-1]; } int main( ) { int b[20]; Pascal(b,1); printf("%d\n",b[1]); Pascal(b,3); printf("%d\n%d\n",b[0],b[2]); return 0; } 9(单选题): 若有声明“int b=1,c[10]={2},*x=c; ”,则以下语句中正确的是__________ 。
编写时按步骤给分
|