t=*c0; *c0=*c1; *c1=t; } main() { int a[2]={3,5}, b[2]={3,5}; swap1(a, a+1); swap2(&b[0], &b[1]); printf("%d %d %d %d\n",a[0],a[1],b[0],b[1]); } 程序运行后的输出结果是 A)3 5 5 3 B)5 3 3 5 C)3 5 3 5 D)5 3 5 3 (41)有以下程序 #include main() { char p[]={’a’, ’b’, ’c’}, q[10]={’a’, ’b’, ’c’}; printf("%d %d\n", strlen(p), strlen(q)); } 以下叙述中正确的是 A)在给p和q数组置初值时,系统会自动添加字符串结束符,故输出的长度都为3 B)由于p数组中没有字符串结束符,长度不能确定;但q数组中字符串长度为3 C)由于q数组中没有字符串结束符,长度不能确定;但p数组中字符串长度为3 D)由于p和q数组中都没有字符串结束符,故长度都不能确定 (42)有以下程序,其中函数f的功能是将多个字符串按字典顺序排序 #include void f(char *p[], int n) { char *t; int i,j; for(i=0; i for(j=i+1; j if(strcmp(p[i],p[j])>0){ t=p[i]; p[i]=p[j]; p[j]=t; } } main() { char *p[5]={"abc","aabdfg","abbd","dcdbe","cd"}; f(p, 5); printf("%d\n", strlen(p[1])); } 程序运行后的输出结果是 A)2 B)3 C)6 D)4 (43)有以下程序 # include void f(char *s, char *t) { char k; k=*s; *s=*t; *t=k; s++; t--; if (*s) f(s, t); } main() { char str[10]="abcdefg", *p ; p=str+strlen(str)/2+1; f(p, p-2); printf("%s\n",str); } 程序运行后的输出结果是 A)abcdefg B)gfedcba C)gbcdefa D)abedcfg (44)有以下程序 float f1(float n) { return n*n; } float f2(float n) { return 2*n; } main() { float (*p1)(float),(*p2)(float),(*t)(float), y1, y2; p1=f1; p2=f2; y1=p2( p1(2.0) ); t = p1; p1=p2; p2 = t; y2=p2( p1(2.0) ); printf("%3.0f, %3.0f\n",y1,y2); } 程序运行后的输出结果是 A)8, 16 B)8, 8 C)16, 16 D)4, 8 (45)有以下程序 int a=2; int f(int n) { static int a=3; int t=0; if(n%2){ static int a=4; t += a++; } else { static int a=5; t += a++; } return t+a++; } main() { int s=a, i; for( i=0; i<3; i++) s+=f(i); printf("%d\n", s); } 程序运行后的输出结果是 A)26 B)28 C)29 D)24 (46)有以下程序 # include struct STU { int num; float TotalScore; };
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
|