• You can kind of see where the syntax is going, looks like a loop, but you can kind of put blocks inside of you, and the little arrow suggests that once you get to the bottom just like our socks example, you're gonna do the following again.

    从某种程度上你可以看到它的语法构成,像个循环,你也可以把,一些程序块放到循环中,如同短袜的例子,这个小箭头暗示你一旦到达底部,你将会重复接下来的事情。

    哈佛公开课 - 计算机科学课程节选

  • Well, you'll know when it crashes, that doesn't help you very much, but you can't always tell whether something's stuck in an infinite loop or whether it's simply taking a long time to compute.

    好,你将学到它在什么时候会崩溃,这对你帮助并不大,但是你不能辨别出到底是在一个循环中,有什么东西卡住了呢,还是程序需要很长的时间来计算一个结果呢。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • 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循环,这只是使你的代码看起来稍微有点不同。

    哈佛公开课 - 计算机科学课程节选

  • They're running through a loop. It's a common way of thinking about problems.

    有继承意义的迭代程序了,它们是以循环的模式来运行的。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And those are two things that you'd like to do with every looping construct you write: you'd like to be able to assure yourself that they will always terminate, and then the second thing you'd like to do, is to assure yourself that it does give you back a reasonable answer.

    就是现在我有了能去检查程序,是不是做了正确的操作的能力:,这就是你们在写每个循环程序的时候,都要注意的两个事情:,第一件事情是要确保程序可以终结,第二件你要做的事情,就是要确保程序返回了正确的答案。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • OK, once it gets to the end of that, what's it going to do? It's going to come down here and, oh. What's that doing? Well I cheated when I started. I said, somebody's giving me a perfect square, I'm looking for the square root of it. But suppose 15 I gave this thing 15, and asked it to run.

    好,一旦到了循环的最后,程序会去做什么?程序会跳到这里来,噢,这是干什么的?好吧,当我开始的时候我有点小作弊的意思,我说过,我得到了一个完美的平方数,我要求这个数的平方根,但是假设下我得到的数是。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Now this happens to be what we would call a linear process, because the number of times I go around the loop is directly related to the size of the argument. If I double 2 the argument, I'm going to double the number of times I go around the loop. If I increase it by five, 5 I'm going to increase by five the number of times I go around the loop.

    这恰好是我们会成为,线性复杂度程序的一个例子,因为我要执行循环的次数是,和输入的参数的大小直接相关的,如果我将这个参数乘以,那么我就要将进行循环的次数也乘以2了,如果我把参数加上,那么循环的次数也要加上5了。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • But that little short hand there is doing exactly the same thing. It is adding that value into some digits and putting it back or signing it back into some digits. And I'll walk through that loop and when I'm done I can print out the total thing does. And if I do that, I get out what I would expect.

    加上得到的这个数的,但是这个缩写声明其实是进行了同样的操作,它把我们得到的这个数加到一个数上面去,然后用和对这个数进行了重新赋值,在循环中会去遍历字符串,当完成循环后,程序会显示数字的总和,如果我运行,这个程序的话,我会得到我期待的结果。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I probably whip out a do while loop very rarely, but very often when programming games or any program that takes user input and has to check that user input and yell at the user if they're messing with you or aren't providing what's expected.

    我可能很少用do,while,循环,但常常是,当编制程序游戏或需要用户输入的程序是,需要检查用户的输入并提醒用户,如果他们干扰了你,或没有提供所期望的输入。

    哈佛公开课 - 计算机科学课程节选

  • And if I were to use that again, I'd just put it on your handout, I could go back and rewrite that thing that I had previously for finding the square roots of the perfect squares, just using the FOR loop. OK. What I want to do, though, is go on to-- or, sorry, go back to - my divisor example.

    它可以是任意的集合,如果我又要去用这个方法的话,我会把它放在你们的课堂手册上的,我可以回过头去用FOR循环,重新写我们那个求平方数的程序,我想要做的是,是继续-哦抱歉,回到-我的除数那个例子。

    麻省理工公开课 - 计算机科学及编程导论课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定