• Once each time. Right? I only do one swap potentially, it-- though not one potentially, each time at the end of the loop I do a swap.

    每次循环做一次,对么?我其实,就可能做了一次交换,也许并不是可能,每次循环的结束我都得做一次交换。

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

  • Well I ought to be able to do that by simply generalizing the loop. And that's what the next piece of code on your a hand out shows you.

    好的通过生成这个循环,我应该能够达到目的,这也是你们的讲义中下一段代码。

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

  • So what I wanted to do is loop back, at least with a couple of things that we see recurring and very understandably so, but let's try to clear up a couple of frequently occurring issues.

    所以我想要做的是回环,至少用两三个,我们看到的东西返回,并且可以理解地,让我们试着处理几个,频繁发生的事情。

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

  • And what's this little loop say to do? This little loop says I'm going to write a function or procedures that takes in two messages.

    这个小循环是做什么的,这个小的循环是,我要写一个函数或者过程来接受两条消息。

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

  • Nonetheless, having done that, let's look at what I'm going to do. I now want to run a loop where I need to collect things together.

    尽管如此,讲完了这些,让我们去看看,我将要进行的操作,我想要运行一个,需要把东西收集起来的循环,我要命名它。

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

  • On line 2, we're gonna induce what's called a loop, so do you wanna go ahead and Philip henceforth you get to stare, stare at the awkwardness.

    第二行,我们将介绍什么叫做循环,你想接着往下读吗,飞利浦正盯着你看,略显尴尬。

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

  • I can be a little more careful about keeping track of what goes on inside of that loop. If I don't have any more work to do, let me just stop.

    我能更小心点来跟,踪循环里发生了什么,如果没什么可干的了,就停下来吧。

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

  • swap I'm going to keep track of a little variable called swap, it's initially true, and as long as it's true, I'm going to keep going, but inside of the loop I'm going to set it to false, and only if I do a swap will I set it to true.

    我打算跟踪一个小的变量称为,初始值为真,只要它是真的,算法就会继续,但是在循环里,我打算把他设为假,除非交换发生,就把它设为真。

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

  • I'm going to have it take in as input how many legs I got, how many heads do I have, and I just want to write a little loop.

    这就是解决问题的思路,我将要输入我有多少条腿,以及我有多少只头。

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

  • Do nothing, close your loop and then down here do something.

    不做什么,关闭你的循环,然后到这里做点事情。

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

  • We start with j pointing here, and we can see what this loop's going to do, right? j is just going to move up.

    我们让j指向这里,我们能看到这个,循环要做什么?,对吧,j要开始移动了。

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

  • You do that on loop too long, it gets really annoying quickly.

    不过如果不停叫,就有点烦人了。

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

  • How do I know when I'm done with the loop?

    我怎么知道循环完毕了呢?

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

  • The inner loop, this part here, I do m times.

    这个循环执行了多少次呢?

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

  • What's the first thing I do in a loop?

    我在循环中做的第一件事情是什么呢?

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

  • How many times do I go through the loop?

    那我执行了多少次循环呢?

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

  • And so what's the loop going to do?

    字符的序列来对待了?

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

  • Sorry? OK. You're doing the whole thing for me What's the complexity just of this inner loop m How many times do I go through that loop?

    就这一块代码的,我执行了多少次这个循环?,次对不对?,here?,Just,this,piece。,我一会儿就会去得到你的答案的?

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

  • 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.

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

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

  • And so when you start to poke around the puzzle pieces, you see that it can say things, we'll see movement in just a moment and sound and so forth, but at the end of the day, this is just like the program we used a moment ago for the sock exercise where we just hold Philip a step after step after step, do this, do this, do that, and yet, here too, we already see an opportunity for that thing we called the loop.

    如果你认真看下这些拼图,你会发现它都是一些移动,并发出声音的功能块,就像我刚才的,练习程序一样,我们让飞利浦做这个动作,做那个动作,跟这里的情况一样,我们已经看到了称为循环的东西。

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

  • 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上使用它时。

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

  • The difference with the do while loop, as the syntax kind of suggests, is that this construct is going to do something no matter what.

    作为建议的语法,do,while循环的不同之处,是这个结构不管怎么样,它会做一些事情。

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

  • 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函数。

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

  • 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,循环,但常常是,当编制程序游戏或需要用户输入的程序是,需要检查用户的输入并提醒用户,如果他们干扰了你,或没有提供所期望的输入。

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

  • So this do while loop immediately breaks out at the point of that check.

    所以这个do,while,循环在检查的时候,直接中断了。

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

  • 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循环。

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

  • How many times do I go through that loop?

    我都要去做m个操作?

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

  • I get to the end of the loop, and I actually do a little bit of wasted motion there. And the little bit of wasted motion is, I take the value at i, store it away temporarily, take the value where min index is pointing to, put it back in there, and then swap it around.

    我走到了循环的末尾,事实上我做了多余的动作了,有点多余的是我把i的值,临时保存起来了,看看MinIndex指向的值,放回到哪里,然后再交换。

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

  • 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循环,重新写我们那个求平方数的程序,我想要做的是,是继续-哦抱歉,回到-我的除数那个例子。

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

  • So the question was, why is this return down at this level, it says, well if I ever execute out of this FOR loop, I get to the end of the FOR loop without hitting that branch that took me through the return, then and only then do I want to actually say, gee, I got to this place, there isn't any value to return, none I'm going to return none and none.

    问题是,为什么它是在这个级别上返回值呢,意思就是如果我出了这个for循环,就意味着我运行的过程中没有走到任何,带return的支路上去,这时也只有这时我才能说天呐,我终于走到这儿了,这时不会返回任何值,只会返回none和。

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

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

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

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