问题
单项选择题
若有如下程序: main() {int x=1,n; for(n=0;n<5;n++) {switch(n) { case 3:x+=3; case 2:x+=2; case 1: case 0: default:x+=4; } } printf("%d\n",x); } 则程序执行后的输出结果是 ( )
A.10
B.18
C.28
D.30
答案
参考答案:C
若有如下程序: main() {int x=1,n; for(n=0;n<5;n++) {switch(n) { case 3:x+=3; case 2:x+=2; case 1: case 0: default:x+=4; } } printf("%d\n",x); } 则程序执行后的输出结果是 ( )
A.10
B.18
C.28
D.30
参考答案:C