do-while循环的目的是什么? [英] What is the purpose of a do-while loop?
本文介绍了do-while循环的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道它做了什么,以及它如何与while循环合作,但是不会有一个while循环代码是相同的,无论是否存在?
I know what do does, and how it cooperates with the while loop, but won't a while loop code be the same, whether or not the do is there?
推荐答案
请考虑以下因素:
while(condition){
myFunction();
}
和
do{
myFunction();
}while(condition);
第二个表格执行 myFunction()
at至少一次检查条件
!要使用进行
循环,你要编写:
The second form executes myFunction()
at least once then checks the condition
! To do so with a while
loop you've to write:
myFunction();
while(condition){
myFunction();
}
这篇关于do-while循环的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文