do while循環(huán)語(yǔ)句例子 do loop循環(huán)語(yǔ)句格式?
do loop循環(huán)語(yǔ)句格式?例如:I=1doprint II=I 1loop while I<=3這里,< condition determination>是I<=3;initial
do loop循環(huán)語(yǔ)句格式?
例如:
I=1
do
print I
I=I 1
loop while I<=3
這里,< condition determination>是I<=3;
initial I=1,輸入do loop
第一個(gè)循環(huán);
print I,output 1
execute I=I 1,I等于2
execute loop while I<=3,因?yàn)镮=2的結(jié)果,I<=3如果為true,則繼續(xù)循環(huán)并執(zhí)行do。
第二個(gè)循環(huán);
執(zhí)行print I,output 2
執(zhí)行I=I 1,I等于3
在I<=3時(shí)執(zhí)行循環(huán),因?yàn)镮=3,I<=3的結(jié)果為真,請(qǐng)繼續(xù)循環(huán)并執(zhí)行do。
第三個(gè)循環(huán);
execute print I,output 3
執(zhí)行I=I 1,I等于4
在I<=3時(shí)執(zhí)行循環(huán),因?yàn)镮=2,I<=3的結(jié)果為false,循環(huán)結(jié)束。
循環(huán)語(yǔ)句的符號(hào)?
循環(huán)語(yǔ)句
for、while和do while語(yǔ)句。
循環(huán)語(yǔ)句由循環(huán)體和循環(huán)終止條件組成。在許多實(shí)際問題中,有許多規(guī)律的重復(fù)運(yùn)算,因此有必要在程序中重復(fù)一些語(yǔ)句。一組重復(fù)的語(yǔ)句稱為循環(huán)體。能否繼續(xù)重復(fù)決定了循環(huán)的終止條件。