【发布时间】:2019-06-11 17:30:50
【问题描述】:
下面的递归会打印出什么样的数字序列 如果我们以 N 为值 1 启动它?
procedure Exercise (N)
print the value of N;
if (N < 3) then (apply the procedure Exercise to the
value N + 1);
print the value of N.
正确答案假设是 123321,但我尝试自己回答,我得到了 1233
【问题讨论】:
-
你忘记了第二个“打印N的值”。
-
如果您编写代码并执行算法,您可以轻松检查这一点。