C语言Ackerman函数:我看不懂答案的意思!求助!!!
以下是课本提供的代码:#include<stdio.h>
#include<stdio.h>
long int ack(int m,int n)
{
long int value;
if(m<0||n<0)
{
printf("\nThe condition of caculating is not exist,EXIT!\n");
exit(1);
}
if(m==0)
{
value=n+1;
printf("ack(0,%d)=%d\n",n,n+1);
}
else if(n==0)
{
value=ack(m-1,1);
printf("ack(%d,1)=%d\n",m-1,ack(m-1,1));
}
else
{
printf("ack(%d,%d)=ack(%d,ack(%d,%d))\n",m,n,m-1,m,n-1);
value=ack((m-1),ack(m,n-1));
}return value;
}
int main()
{
int mm,nn;
long int a;
printf("\nPLEASE ENTER M & N:");
scanf("%d%d",&mm,&nn);
a=ack(mm,nn);
printf("\nack(%d,%d)=% ld\n",mm,nn,a);
return 0;
}
PLEASE ENTER M & N:1 3
ack(1,3)=ack(0,ack(1,2))
ack(1,2)=ack(0,ack(1,1))
ack(1,1)=ack(0,ack(1,0))
ack(0,1)=2 /*这一步看得懂*/
ack(0,1)=2 /*这一步开始就看不懂了*/
ack(0,1)=2
ack(0,2)=3
ack(0,3)=4
ack(0,4)=5
ack(1,3)= 5
Press any key to continue