meili 发表于 2022-10-27 16:12:35

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

<p>问题:执行下面程序段后,i的值是(A).intinti=10switch(i){case9:i+=1;case10:i--;case11:i*=3;case12:++i;}A、28B、10C、9D、27为什么是28?
<p>答案:↓↓↓<p class="nav-title mt10" style="border-top:1px solid #ccc;padding-top: 10px;">贺国军的回答:<div class="content-b">网友采纳  当然是28了,程序在switch语句中case10:这里执行i--之后i=9,然后没有Break语句,接着执行下面的case11:,i*=3,此时i的值为27,后面又没有break语句,所以程序执行case12的++i,然后退出switch语句,所以i=28
页: [1]
查看完整版本: 执行下面程序段后,i的值是(A).intinti=10switch(i){case9:i+=1;case10:i--;case11:i*=3;case12:++i;}A、28B、10C、9D、27为什么是28?