And we won't wait here one hundred seconds for it to finish, but we're using the loop, we're updating a variable, and we're formatting it in a nice way.
我们将不会再这里等待100秒来等它完成,但是我们使用循环,我们更新一个变量,我们把它排成一个漂亮的格式。
OK, so what have I done? I just added a little bit more now. I'm now running through a pair of loops. Again notice the encapsulation, that nice abstraction going on, which is what I want. Once I get to this stage though by the way, there might be more than one solution.
我现在运行了一对循环,再一次注意这个封装,抽象得很好,这就是我想要的结果,我按这种方式走到这一步的时候,可能会有多组答案。
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函数。
You start off and you go down, down, down, and then you come up, then you get your first REM cycle, again, again, again, again, again, and then you wake up.
从第一阶段开始,到下面的阶段,然后又往上,这时就出现REM睡眠,然后再一次次地循环,直到你睡醒。
Go through the second round of the loop.
再做第二遍循环。
Ah ha, it goes into that accept portion, prints out a message, and goes back around the while loop to say try again. And it's going to keep doing this until I give it something that does serve as a float.
他会说输入一个浮点数,啊哈,它就到了那段处理代码,打印出消息,然后回到while循环让我们再输一次,它会持续这么做直到它接受到一个浮点数。
At the end of the day, you can implement the exact same program using a while loop that you can using a for loop, it's just your code is going to look slightly different.
最终,你可以执行这个程序,再使用for循环的地方使用while循环,这只是使你的代码看起来稍微有点不同。
Next time through the loop it goes to a cubed.
然后再一次循环变成a的三次方。
应用推荐