So first of all, I've got to be careful about the end test. But the second thing is, OK, if it stops whenever this is less than two, am I convinced that this will always halt?
小心最后一次比较,其次,如果少于两个元素程序停止了,我们能确信这总是应该终止的么?,答案是肯定的,因为我在做什么?
What I mean by that is, pick a simple set of values, and let's walk through it to see what happens. And this is useful because it's going to allow me to A make sure that I've got something that's going to terminate, it's going to let me make sure that in fact I'm doing the right kinds of updates.
原因你们知道的,好,模拟代码,我的意思就是,选出一系列的值来,然后模拟下代码的执行来看看结果,这很有用因为这让我确保我的程序在某个地方,可以终止,还会让我确保实际上我。
I can't give it what it wants," know that when you're writing code and the problems that will remind of this, if you absolutely have to kill your program, you don't have to close the window, CTRL+C reboot crazy stuff like that, generally you can hit CTRL+C and it will just abort the program right where it is, in case you ever get trapped in some awkward situation.
我不能给它所要的“,当你在写代码时,程序将,提醒这个问题,如果你不得不,关闭这个程序,你不需要关闭这个窗口,重启像那样的疯狂举动,通常你可以敲,它将会在这个地方终止那个程序,假使你陷入了尴尬的处境。
It terminates your program.
它终止了你的程序。
All right, first question. What values of x does it terminate? Again, assume x is an integer.
好,第一个问题,对于x的什么值程序,会最终终止,还是假设x为整数。
And in fact, now let me ask those two questions about this piece of code. First question is, for what values of integers-- we're going to assume integers-- but for what values of x does this code terminate? And the second question is, for what values of x does it give me back the right answer?
实际上,让我关于这块代码问两个问题,第一个问题是,对于什么样的整数值,我们会假设是整数,对于x的什么值程序,会最终终止?第二个问题是,对于x的什么值程序,会返回正确答案?
应用推荐