How could we use DOES-HALT to determine if a program produces the correct output for a specific input? Keep in mind that DOES-HALT does just that — it halts.
对于一个特定的输入来说,我们如何用DOES - HALT判断程序是否产生了一个恰当的输出呢?
Now, all we need to do is run DOES-HALT (COMPARE-OUTPUT, [program, input, expected output]) to know whether or not program passes the test case, input, and outputs the expected output.
现在,我们所要做的全部事情就是运行DOES - HALT (COMPARE - output,[program,input,expected output]),这样一来我们就会知道程序是否通过了测试用例,输入,和输出预期的输出。
That means work on this input will halt, as it should.
这意味着在此的输入作业将停止,因为它应该停下。 但如果它检测到一个不可停止的循环,那么P报告"Bad"!
Some programs might never halt when run on themselves, though -- so let's use DOES-HALT to write pseudo-code for a program that checks to see what happens when a program is given itself as input.
有些程序在把它们自己当作输入运行时,可能永远不会停下来,既然这样——那么让我们用DOES-HALT编写一端伪代码,用它来测试当一个程序把它自己作为输入参数时会发生什么好了。
Some programs might never halt when run on themselves, though -- so let's use DOES-HALT to write pseudo-code for a program that checks to see what happens when a program is given itself as input.
有些程序在把它们自己当作输入运行时,可能永远不会停下来,既然这样——那么让我们用DOES-HALT编写一端伪代码,用它来测试当一个程序把它自己作为输入参数时会发生什么好了。
应用推荐