• All right? The first one is, that test has to involve-- shouldn't have to, the value of some variable.

    好不好?第一件事是,循环开始的测试必须必须-不是一定,一些变量的值。

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

  • So this is a nice little search-- sorry, a nice little sort algorithm . And in fact, it's relying on something that we're going to come back to, called the loop invariant.

    恩,这是一个很棒的小搜索,抱歉,和很棒的小排序算法,事实上,它依赖于一些我们要回顾的东西,被称作循环变量

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

  • 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秒来等它完成,但是我们使用循环,我们更新一个变量,我们把它排成一个漂亮的格式。

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

  • And I want to remind you, that block of code is a set of instructions, the same set of instructions that are going to be done each time through the loop.

    我想提醒大家,这块代码是一个指令集,一个每次循环都会被执行的相同指令集,会变化的仅仅是变量的值。

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

  • The loop invariant what does the loop invariant mean? It says, here is a property that is true of this structure every time through the loop.

    循环变量是什么意思?,它是一个在结构体中,每次循环都为真的属性。

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

  • So it's initialized outside the loop when it should be initialized inside the loop. Or conversely, inside the loop when it should be outside the loop. So look carefully at when variables are being initialized.

    却忘记了,意思就是它本来应该,是在循环外初始化,但是却是在循环初始化的,所以在初始化变量的时候注意这一点。

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

  • What if I don't change the value of that variable inside of the code?

    那么如果在循环内部,我不改变这些变量的值会怎么样?

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

  • All right. Second question: or maybe a better way of saying this, and the general format you're likely to see here is, a test involving a variable name, which must be initialized outside of the loop, and which interior to the loop gets changed, so that the test is going to change.

    好,第二个问题:,换种更好的方式来说吧,你们通常喜欢的,方式是,这个测试涉及到一个变量名字,变量循环外已经被初始化,然后循环内部会改变这个变量的值,因此测试结果会改变。

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

  • Now I seem to be violating my own mantra here by just calling this variable A, but this is reasonable, I much as with four loops when you just call an incrementing variable I, because you just need an index, well, same here.

    现在我好像违背了我自己的意愿,我把这个变量叫做A,但这是合理的,就像我们的for循环中,我们把一个增变量叫做,因为我们只要一个索引,这里也一样。

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

  • And remind you that inside of here, I'd better be changing the variable. All right, if that variable that's counting is not changing I'm going to be stuck in an infinite loop, so I ought to that, right, expect somewhere in there, a change of that variable. All right?

    我最好改变了计数器的变量值,好,如果计数的变量没有变化的话,我就会被卡在一个无限循环里面,因此我应该【不可闻的声音】,对,在这里的某个地方,改变下计数器的变量,对不对?我要做的最后一件事情就是?

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

  • Because the for loop hands me placeholders in between those semicolons for variables and such, now I don't have those with while loops.

    因为for循环给我提供了为变量准备的占位符,它们在分号之间,现在在while循环中,我没有这些。

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

  • In this case, it's doing the check on the remainder and printing them out.

    请注意,几乎一样的形式:,首先挑出在循环中会改变的变量

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

  • Initialization. A very common bug is to initialize a variable. Go through a loop, and then forget to reinitialize it when it needs to be reinitialized again.

    忘记初始化,忘记初始化变量是一个很常见的错误,运行完一个循环之后,当需要再次初始化时。

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

  • But notice unlike a for loop, if you want to declare a variable or increment or decrement to variable, you've got to do that yourself.

    但请注意不像for循环,如果你想声明一个变量,或者变大或变小一个变量,你需要自己完成。

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

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

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

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