c语言编程求大佬

2024-12-03 20:56:17
推荐回答(2个)
回答1:

#include

int ack(int m,int n)

{if(m==0)return n+1;

if(m>0&&n==0)return ack(m-1,1);

return ack(m-1,ack(m,n-1));

}

int main()

{ int m,n;

scanf("%d%d",&m,&n);

printf("A(%d,%d)=%d\n",m,n,ack(m,n));

return 0;

}

回答2:

int A(int m,int n);
void main()
{
int m,n;
printf("输入两个整数:\n");
scanf("%d%d",&m,&n);
printf("A(%d,%d)=%d\n",m,n,A(m,n));
}

int A(int m,int n)
{
if(m==0)return n+1;
if(m>0&&n==0) return A(m-1,1);
if(m>0&&n>0)return A(m-1,A(m,n-1));
}