The Ackermann function is defined recursively for non-negative integers m and n as follows (this presentation is due to Rózsa Péter):
A(m,n)=n+1 if m=0
=A(m-1,1) if m>0 and n=0
=A(m-1,A(m,n-1)) ifm>0 and n>0
要求:
从标准输入中读入一组m和n,两者以空格分隔,输出A(m,n)的值以及计算A(m,n)的全部计算过程
#include
using namespace std;
int Ackermann(int m, int n) { if (m == 0) { cout<< "Ackermann "< 0 && n == 0) { cout<< "Ackermann "<0 && n> 0) { cout<< "Ackermann "<>m>>n; cout<