函数定义如下:
#include<iostream>
using namespace std;
int Ack(int m, int n) {
if (0 == m) {
return n + 1;
}
else if(m>0&&0==n) {
return Ack(m - 1, 1);
}
else if (m > 0 && n > 0) {
return Ack(m - 1, Ack(m, n - 1));
}
}
int main() {
while (true) {
int m, n;
cin >> m >> n;
if (0 == m)
break;
else
cout << Ack(m, n) << endl;
}
return 0;
}
tips:
递归
视频原地址: