[填空題] 執(zhí)行下列程序段后輸出的結(jié)果是______。 public class Test public static void main(String
2021-07-20
[填空題] 執(zhí)行下列程序段后輸出的結(jié)果是______。
public class Test
public static void main(String args[])
int x,y;
for(y=1,x=1;y<=50;y++)
if(x>=10)break;
if (x%2==1)
x+=5;
continue;
x-=2;
System.out.println(y);正確答案:
F
參考解析:本題是對for循環(huán)和if條件語句的綜合考查。當y=1,x=1時不滿足第1個 if語句,向下繼續(xù)執(zhí)行第2個if語句x=6,繼續(xù)執(zhí)行 for循環(huán);當y=2,x=6時,不滿足第1個和第2個 if語句,x=3,繼續(xù)執(zhí)行for循環(huán);當y=3,x=3時,不滿足第1個if語句,向下繼續(xù)執(zhí)行第2個if語句 x=8,繼續(xù)執(zhí)行for循環(huán);一直執(zhí)行下去,直到y(tǒng)=6, x=12時滿足第1個if語句,退出for循環(huán)。
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。