下列程序的运行结果是( )。 main() { int a=-5,b=1,c=1; int x=0,y=2,z=0; if(c>0)x=x+y; if(a<=0) { if(b>O) if(c<=0)y=x-y; } else if(c>0)y=x-y; else z=y; printf("%d,%d,%d\n",x,y,z); }
A.2,2,0
B.2,2,2
C.0,2,0
D.2,0,2
第1题:
下列程序的运行结果是( )。main(){ int a=-5,b=1,c=1;int x=0,Y=2,z=0; if(c>0)x=x+ y; if(a<=0) { if(b>0) if(c<=0)y=x-y; } else if(c>0)Y=x-y; else z=y; printf("%d,%d,%d\n",x,y,z);}
A.2,2,0
B.2,2,2
C.0,2,0
D.2,0,2
第2题:
下列程序的运行结果是( )。 #include<stdio.h> void sub(int*s,int*y) {static int m=4: *y=s[m]; m--; } void main() {int a[]={1,2,3,4,5},k,x; printf("\n"); for(k=0;k<=4;k++) {sub(a,&x); printf("%d,",x); } }
A.5,4,3,2,1,
B.1,2,3,4,5,
C.0,0,0,0,0,
D.4,4,4,4,4,
第3题:
以下程序执行后的输出结果是 #include<iostream> using namcspace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }
A.18
B.9
C.10
D.不确定
第4题:
下列程序的运行结果是( )。 #include<stdio.h> void sub(int*s,int*y) {static int m=4; *y=s[0]; m++; } void main() {int a[]={1,2,3,4,5},k; int x; printf("\n"); for(k=0;k<=4;k++) {sub(a,&x); printf("%d,",x); } }
A.1,1,1,1,1,
B.1,2,3,4,5,
C.0,0,0,0,0,
D.4,4,4,4,4,
第5题:
若有以下程序段; #include<iostream> using namespace std; int main() { int a[]={1,4,5}; int *p=&a[0],x=6,y,z; for(y=0;y<3;y++) z=((*(p+y)<x) ? *(p+y):x); cout<<z<<end1; return 0; } 程序运行后的输出结果是( )。
A.1
B.4
C.5
D.2