Recursive Method!
/*
===========================================
Title: A recursive function program that writes the Ackermann function!
A (m,n) =
- N+1 (m=0)
- A (m-1,1) (m=0)
- A (M-1,a (m,n-1)) (m!=0,n!=0)
===========================================
*/
#include <stdio.h>
int A (int m,int N)
{
if (m==0)
return n+1;
else if (n==0)
Return A (m-1,1);
Else
Return A (M-1,a (m,n-1));
}
void Main ()
{
int m,n,p,flag=1;
while (flag)
{
printf ("m=");
scanf ("%d", &m);
printf ("n=");
scanf ("%d", &n);
P=a (M,n);
printf ("A (%d,%d) =%d\n\n", m,n,p);
}
}
/*
===========================================
Evaluation:
This topic is very simple, has clarified the specific form of recursive function, directly
Write a function, call it! However, if the hand is to be counted, this is a phase
When the complex call process, if you let m and n are calculated from 1 to 10 respectively,
It may take an hour! Take the computer a few minutes to get it done!
===========================================
*/
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
function Call of C language 12-recursive method to find Ackerman function