@H_419_2@/**@H_419_2@
while @H_419_2@循环@H_419_2@
@H_419_2@
while @H_419_2@循环保持条件@H_419_2@
{@H_419_2@
// @H_419_2@执行指令@H_419_2@
}@H_419_2@
*/@H_419_2@
@H_419_2@
@H_419_2@var@H_419_2@ i:@H_419_2@Int@H_419_2@ = @H_419_2@1@H_419_2@
@H_419_2@var@H_419_2@ sum:@H_419_2@Int@H_419_2@ = @H_419_2@0@H_419_2@
@H_419_2@
@H_419_2@
#if@H_419_2@ @H_419_2@false@H_419_2@
@H_419_2@
@H_419_2@// @H_419_2@先判断条件,再执行语句@H_419_2@
@H_419_2@while@H_419_2@ i <= @H_419_2@100@H_419_2@ {@H_419_2@
sum += i@H_419_2@
i = i+@H_419_2@1@H_419_2@;@H_419_2@
@H_419_2@
@H_419_2@// swift 3 @H_419_2@不要@H_419_2@ ++ -- @H_419_2@了@H_419_2@
// i++;@H_419_2@
}@H_419_2@
#endif@H_419_2@
// print(sum)@H_419_2@
// print("-------------->")@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@
@H_419_2@ // @H_419_2@不管条件满不满足,先执行语句,再判断条件@H_419_2@
@H_419_2@/**@H_419_2@
do-while@H_419_2@
@H_419_2@用@H_419_2@ repeat-while instead@H_419_2@
*/@H_419_2@
@H_419_2@
@H_419_2@repeat@H_419_2@ {@H_419_2@
sum += i@H_419_2@
i = i+@H_419_2@1@H_419_2@;@H_419_2@
} @H_419_2@while@H_419_2@ (i <= @H_419_2@100@H_419_2@)@H_419_2@
@H_419_2@
@H_419_2@print@H_419_2@(sum)@H_419_2@
总结以上是内存溢出为你收集整理的4.3 Swift中while循环语句全部内容,希望文章能够帮你解决4.3 Swift中while循环语句所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)