Well, let's take a look at this high7 variant that also use loops that also uses a loop. So this one is a little cute, I like to think. So notice this.
让我们看下这个仍然使用了循环的版本,这个有点意思,我认为,注意这个。
Otherwise, it's a pretty bad mistake, but sometimes you do want an infinite loop, Word for instance, Microsoft Word if you use it or pages or the like on your Mac or PC.
否则,它将会是一个错误,但有时你确实需要一个无穷循环,例如微软的,当你在Mac或者PC上使用它时。
Well in C and other languages that we'll see this semester, you use what's called the for loop, and this as syntax isn't quite as straightforward but once you know what to look for, it's very easy to understand.
在C语言和一些我们这学期将要接触的编程语言中,你将会用到所谓的for循环,也许作为一种语法规则,它看起来不是那么的通俗易懂,但是你一旦知道曲中奥妙,就不难理解了。
Then we have to steal the code from earlier to do a forever loop, a while true loop and then I'm gonna go ahead and use that printf thing that we saw.
然后再借用先前的代码,做一个永久性的循环,即while循环,紧接着需要用到一个,之前我们看到过的printf函数。
So conceptually the key difference here, besides the syntax looking slightly different, it just means that if you want a chunk of code to execute no matter what initially, ; you can use the do while loop; if you want to check a condition first, you can use the while loop.
所以概念上,则关键的区别是,除了语法看起来有点不同,它的意思是如果你想要一段代码,最初无论如何都要执行,你就可以用do,while循环;,如果你想要先检查条件,你可以用while循环。
应用推荐