Ackerman函数的递归算法是什么?
收起
知与谁同
2018-07-22 18:36:39
1682
0
1
条回答
写回答
取消
提交回答
-
#include <stdio.h>
#include <stdlib.h>
int Ackerman(int m, int n);
int main()
{
int i = 5, j = 5;
printf("%d\n",Ackerman( 5, 5));
return 0;
}
int Ackerman( int m, int n )
{
if((m <0)||(n <0))
{
exit(1);
}
if( m == 0 )
{
return n+1;
}
else if( n == 0 )
{
return Ackerman( m-1, 1 );
}
else
{
printf("%d,%d\n",m,n);
return Ackerman( m-1, Ackerman( m, n-1 ) );
}
}
2019-07-17 22:55:37