So at this point in the story, we're not gonna forge ahead to here or to here, or the last two lines.
那么这时,我们并不能继续执行,这行或这行,或者说后两行的指令。
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.
我想提醒大家,这块代码是一个指令集,一个每次循环都会被执行的相同指令集,会变化的仅仅是变量的值。
We might say, even if we are smart enough to build programs that can, by mechanistically following the program, do things we've never thought of.
我们或许说,即使我们非常聪明,可以编制些,能够机械地执行指令的程序,做一些我们从来没想到的事情
So in your mind, if you are now the computer program and you are executing this thing from top to bottom, what just has happened verbally is we are stepping into the line of code that says sort left half of elements.
在你们看来,如果你现在是计算机程序,正在从上到下执行一系列指令,刚才所发生的就是我们现在已执行到了这行代码,它告诉你要对左半部分的元素排序。
Having executed this instruction, that counter goes up by one and we move to the next one.
执行过这个指令之后,计数器升了一级,于是我们开始下一次的运算。
What that means, in a stored-program computer, is that I can provide to the computer a sequence of instructions describing the process I want it to execute.
它的意思就是说,我可以给一个存储程序计算机,提供一系列,描述我希望,能执行的过程的指令。
Well at most, I'm going to execute each instruction once. All right?
那么至多的话,我会执行,每个指令一次,对不对?
That is, it's at most the length of the actual number of instructions.
也就是,它至多会执行,和实际指令数一样多的指令。
If it is true, execute the sequence of instructions.
如果是的话,执行这一块的指令。
We execute that instruction, we move to the next one.
我们执行那个指令,我们继续下一轮。
So, evaluate the same sequence of instructions again.
那么再去执行一遍,相同的指令。
Remember last time, I said that there's different kinds of complexity in our code, and I suggested for simple branching programs, the amount of time it takes to run that program is, in essence, bounded by the number of instructions, because you only execute each instruction at most once.
但是这里有个很重要的点,记得上节课,我提过在我们的代码中,有不同种类的复杂度,而且我还说了对于简单的分支程序,运行这种程序需要的总体时间,大体上,是和指令的数目相关的,因为每个指令只会被执行最多一次。
But literally all I can do at this stage is write what we would call a straight-line program, that is, a program in which we execute in which we execute the sequence of instructions one by one.
但是字面上来说,我们现在学到的,都是所谓的直线程序,也就是,一个接一个的执行,一系列的,指令的程序。
It ran through that sequence of instructions, in particular it bound x to the value three, x and then it took x times x, got the value of x multipied by x, which of course is nine, bound that to the value of x, and then it printed out the value, and now it's sitting here waiting for an input.
程序按照指令的顺序去执行的,首先是把x和3这个值进行了绑定,然后把x乘以,得到了x乘以x的值,当然也就是9了,然后把x和这个值进行了绑定,然后显示出这个值,然后就等待输入。
应用推荐