执行下面程序段后,i的值是(A).intint i=10switch(i){case 9:i+=1; case 10:i--;case 11:i*=3;case 12:++i;} A、28B、10C、9D、27为什么是28?

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/12 22:13:23
执行下面程序段后,i的值是(A).intint i=10switch(i){case 9:i+=1; case 10:i--;case 11:i*=3;case 12:++i;} A、28B、10C、9D、27为什么是28?

执行下面程序段后,i的值是(A).intint i=10switch(i){case 9:i+=1; case 10:i--;case 11:i*=3;case 12:++i;} A、28B、10C、9D、27为什么是28?
执行下面程序段后,i的值是(A).int
int i=10switch(i){case 9:i+=1; case 10:i--;case 11:i*=3;case 12:++i;
}
A、28
B、10
C、9
D、27
为什么是28?

执行下面程序段后,i的值是(A).intint i=10switch(i){case 9:i+=1; case 10:i--;case 11:i*=3;case 12:++i;} A、28B、10C、9D、27为什么是28?
当然是28了,程序在switch语句中case 10:这里执行i--之后i = 9,然后没有Break语句,接着执行下面的case 11:,i*=3,此时i的值为27,后面又没有break语句,所以程序执行case12的++i,然后退出switch语句,所以i=28