下面程序的输出结果是() main() {int a〔 〕={1,2,3},s,b,*p; S=l: P=a: for(b=0;b<3.b++) s*=*(p+b); printf(”s=%d\n”,s);}
第1题:
下面程序的输出结果是( )。#include "string.h"fun(char*w,int n){ char t,*s1,*s2;s1=w; s2=w+n-1;while(s1<s2){ t=*s1++;*s1=*s2--;*s2=t;}}main(){ static char p[]="1234567";fun(p,strlen(p));printf("%s",p);}A.7654321 B.1717171 C.7171717 D.1711717
第2题:
下面程序的功能是输出数组s中最大元素的下标,请填空。
main()
{ int k, p,s[]={1, -9, 7, 2, -10, 3};
for(p =0, k =p; p< 6; p++)
if(s[p]>s[k])【13】
printf("%d\n", k);
}
第3题:
下面程序运行后的输出结果是( )。struct abc{int a,b,c;}main(){struct abc s[2]={{1,2,3},{4,5,6}};int t;t=s[0].a+s[1].b;printf("%d\n",t);}A.5 B.6 C.7 D.8
第4题:
设有如下程序: fun(float*p1,int n,float*p2,int m,float*s) {int i; *s=0.0; for(i=0;i<n;i++)*s+=*p1++; for(i=0;i<m;i++)*s+=*p2++; } main() { float a[]={1.1,2.2},b[]={1.0,2.0,3.0),*s=a; fun(a,2,b,3,s); printf("%f\n",*s); } 上面程序的输出结果是______。
A.8.2
B.9.3
C.3.3
D.1.1
第5题:
下面程序的功能是输出数组s中最小元素,请填空。
include<iostream.h>
void main(){
int k, p, s[]={1,-9,7,2,-10,3};
k=s[0];
for(p=0;p<6;p++)
if(s[p]<k) 【 】;
cout<<k;
}
第6题:
有以下程序:
includedstdio.h>
int f(int n);
main( )
{int a=3,s;
s=f(a);s=s+f(a);printf("%dkn",s);
}
int f(int n)
{static int a=1;
n+=a++;
return n;
}
程序运行后的输出结果是( )。
A.7
B.8
C.9
D.10
本题考查函数的调用。当执行s=f(a)时,进入fun函数,n=n+(a++),n的值为3,a的值为1,a++的意思是先用a的值,再将a加1为2,所以n的结果为4,也就是主函数中f(a)的结果为4;返回主函数,执行s=s+f(a),s为4,再次调用函数,此时n仍为3,a的值刚才已经自加2,所以计算后n的值为5,a自加l为3。返回主函数,f(a)的结果为5,所以s=4+5=9。
第7题:
有以下程序 main( ) { char *s[ ]={"one","two","three"},*p; p=s[1]; printf("%c,%s\n",*(p+1),s[0]); } 执行后输出结果是
A.n,two
B.t,one
C.w,one
D.o,two
第8题:
以下程序运行后的输出结果是。main(){ char s[]="GEFDCBA"; int p=6;While(s[p]!=’D’){ printf("%c",p);p=p-1; }}
第9题:
下列程序的输出结果是______。# include<stdio.h>f(char 8s){ char *p=s; while(*p!='\0')p++; return(p-s);}main(){ printf("%d\n",f("ABCDEF"));}
A.3
B.6
C.8
D.0
第10题:
下列程序的输出结果是( )。 #include <stdio.h> struct abc { int a, b, c, s;}; main() { struct abc s[2]={{1,2,3},{4,5,6}}; int t; t=s[0].a+s[1].b; printf("%d\n",t); }
A.5
B.6
C.7
D.8