0
1
2
4
6
第1题:
下列程序的输出结果是( )。 #include<stdio.h> main() { int a=0,i; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+=1; case 1: case 2:a+=2; default:a+=3; } printf("%d",A) ; }
A.19
B.18
C.6
D.8
第2题:
有以下程序 main( ) { int a=0,i; for(i=1;i<5; i++) { switch (i) { case 0 case 3:a+ =2; case 1; case 2;a+=3; default, a+=5; } } printf("%d\n",a) ; }
A.31
B.13
C.10
D.20
第3题:
A.0
B.1
C.2
D.4
E.6
第4题:
下面程序的运行结果是( )。 define P(A)printf("%d",A)main() {int j,a[]={1,2,3,4,5,6,7},i=5; for(j=3;j>1;j--) {switch(j) {case 1: case 2:P(a[i++]);break; case 3:P(a[--i]); } } }
第5题:
有以下程序
#include<stdio.h>
main( )
{int a[]={2,3,5,4},i;
for(i=0;i<4;i++)
switch(i%2)
{case 0:switch(a[i]%2)
{case 0:a[i]++;break;
case 1:a[i]--;
}break;
case 1:a[i]=O;
}
for(i=O;i<4;i++)prinff(“%d”,a[i]);prinff(“\n”);
}
程序运行后的输出结果是
A.3 3 4 4
B.2 0 5 0
C.3 0 4 0
D.0 3 0 4
第6题:
有以下程序: #include<stdio.h> main() {int a=6,b=7,m=I; switch(a%2) {case 0:m++;break; case 1:m++; switch(b%2) {defaut:m++; case 0:m++;break; } } printf("%d\n",m); } 程序运行后的输出结果是( )。
A.1
B.2
C.3
D.4
第7题:
下列程序的输出结果是( )。 #include<stdio.h> main { int a=0,i; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+=1; case 1; case 2:a+=2; default:a+=3; } } printf("%d",a); }
A.19
B.1
C.6
D.8
第8题:
下列程序的输出结果是 ( ) main( ) { int i,j,m=0,n=0; for(i=0;i<2;i+ +) for(j=0;j<2;j+ +) if(j>=i) m=1; n+ +; printf("%d\n",n); }
A.4
B.2
C.1
D.0
第9题:
写出程序的运行结果。 #include
第10题:
public class Test { public static void main(String Args[]) { int i =1, j = 0; switch(i) { case 2: j +=6; case 4: j +=1; default: j +=2; case 0: j +=4; } System.out.println(“j =” +j); } } What is the result? ()
第11题:
1. int I=1, j=0 2. 3. switch(i) { 4. case 2: 5. j+=6; 6. 7. case 4: 8. j+=1; 9. 10. default: 11. j +=2; 12. 13. case 0: 14. j +=4; 15. } 16. What is the value of j at line 16?()
第12题:
0
2
4
6
9
13
第13题:
以下程序的输出结果是( )。 #include<iostream.h> void main() { int a(5),b(6),i(0),j(0); switch(a) { case 5:switch(b) { case 5:i++;break; case 6:j++;break; default:i++;j++; } case 6:i++; j++; break; default:i++;j++; } cout<<i<<","<<j<<endl; }
A.1,2
B.1,3
C.2,2
D.2,3
第14题:
A.0
B.2
C.4
D.6
E.9
F.13
第15题:
下列语句序列执行后,j的值是( )。 int j=0; for (int i=3 i>0; i- -)j+=i;
A.3
B.4
C.6
D.5
第16题:
下列程序的输出的结果是______。 public class exl6 { public static void main(String[] args) { int j=10; for(int i=0;i<3;i++) { j-=i+1; switch (j){ case 3: break; case 5: break; case 8: break; default: j=0;break; } } System,out.println(j); } }
A.5
B.3
C.8
D.0
第17题:
下列程序的输出结果是【 】。
include<iostream.h>
void main()
{
inta(5),b(6),i(0)1j(0);
switch(a)
{
case 5:switch(b)
{
case 5:i++;break;
case 6:j++;break;
defaun:i++;j++;
}
case 6:i++;
j++;
break;
default:i++;j++;
}
cout<<i<<","<<j<<endl;
}
第18题:
以下程序运行后的输出结果是【 】。
include <iostream.h>
main()
{
int i=10,j=0;
do
{
j=j+ i; i--;
}
while(i>2);
cout<<j;
}
第19题:
有以下程序 #include<stdi0.h> main( ) {int a[]={2,3,5,4),i; for(i=0;i<4;i++) switch(i%2) {case 0:switch(a[i]%2) {case 0:a[i]++;break; case l:a[i]--; }break; case1:a[i]=0; } for(i=0;i<4;i++)printf("%d",a[i]);printf("\n"); } 程序运行后的输出结果是( )。
A.3344
B.2050
C.3040
D.0304
第20题:
下列程序的输出结果是( )。
#include<stdio.h>
main
{ int a=0,i;
for(i=1;i<5;i++)
{ switch(i)
{ case 0:
case 3:a+=1;
case 1;
case 2:a+=2;
default:a+=3;
}
}
printf("%d",a);
}
A.19
B.1
C.6
D.8
第21题:
int I=1, j=0 switch(i) { case 2: j+=6; case 4: j+=1; default: j +=2; case 0: j +=4; } What is the value of j at line 16?()
第22题:
int i = 1,j = -1; switch (i) { case 0, 1:j = 1; case 2: j = 2; default; j = 0; } System.out.println(“j=”+j); What is the result?()
第23题:
j = -1
j = 0
j = 1
j = 2
Compilation fails.
第24题:
3344
2050
3040
0304