阿克曼函数

点击查看代码
#include <iostream>
using namespace std;
int ack(int x,int y)
{
	if (x==0)
	{
		return y + 1;
	}
	else if (x > 0 && y == 0)
	{
		return ack(x - 1, 1);
	}
	else if (x > 0 && y > 0)
	{
		return ack(x - 1, ack(x, y - 1));
	}
}
int main()
{
	int m, n;
	cin >> m >> n;
	cout << ack(m, n) << endl;
	return 0;
}
posted @ 2025-10-10 16:21  一只牛油果  阅读(9)  评论(0)    收藏  举报