⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ackfunction.cpp

📁 实现阿克曼函数并统计递归调用次数 Counting times of recursion calling 1. 问题描述 定义阿克曼递归函数: ACK(0,n)=n+1 n>=0
💻 CPP
字号:
// ACKFunction.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


// ACKfunction.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;

unsigned int  count;



long int ACK(unsigned int  m,unsigned int n)
{	
	int p;
	if(m==0)
	{
		count++;
		return n+1;
	}
	else	if(n==0)
		{	
			count++;
		
			return ACK(m-1,1);
		}
			else
			{
			count++;
			p=ACK(m,n-1);
			return ACK(m-1,p) ;
			}			
	
	
}

void main()
{	
	unsigned int  m;
	unsigned int  n;
	unsigned int  x;
	count=0;
	
	cout<<"input m:";
	cin>>m;
	cout<<"input n:";
	cin>>n;
	x=ACK(m,n);
	cout<<"the result is:"<<x<<endl;
	cout<<"count="<<count<<endl;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -