有以下程序: #include<stdio.h> main() { int a,b; for(a=0;a<3;a++) { scanf("%d",&b); swit

admin2019-01-11  19

问题 有以下程序:
    #include<stdio.h>
    main()
    {
      int a,b;
      for(a=0;a<3;a++)
      {
        scanf("%d",&b);
        switch(b)
        {
        default:printf("%d",++b);
        case 1:printf("%d",++b);
        case 2:printf("%d",++b);
        }
      }
    }
    执行时输入:1 2 3<回车>,则输出结果是(    )。

选项 A、2 3 3 4 5 6
B、2 3 4
C、2 2 3 4 4 4
D、2 3 4 3 4 4

答案A

解析 本题是一个循环结构嵌套选择结构,按照外层循环,内层选择一步一步处理即可。重点注意地是,switch语句中并没有出现break语句,所以内层循环是不会跳出的。
转载请注明原文地址:https://kaotiyun.com/show/Y7xp777K
0

相关试题推荐
最新回复(0)