#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
#define COMPARE(x,y) (((x)<(y)) ? -1 : (((x)==(y)) ? 0 : 1))
using namespace std;
/*
Ackerman函数A(m,n)
A(m,n)={n+1,m==0;A(m-1,1),n==0;A(m-1,A(m,n-1)),其他}
*/
int funcAckerman(int m, int n,int &count)
{
count++;
if (m == 0)
return n + 1;
else if (n == 0)
return funcAckerman(m - 1, 1,count);
else {
return funcAckerman(m - 1, funcAckerman(m, n - 1,count),count);
}
}
int main() {
int count = 0;
funcAckerman(4, 4, count);
cout << count;
return 0;
}
Ackerman函数
最新推荐文章于 2022-10-08 23:38:42 发布