C++ primer plus第六版课后编程题答案7.5


7.5

#include <iostream>
using namespace std;
long jiecheng(int);
void main75()
{
	
	cout<<"Please enter the number:";
	int n;
	
	while(cin>>n)
	{
		long result=jiecheng(n);
		cout<<"the result of jiecheng "<<n<<"! = "<<result<<endl;
		cout<<"Please enter the number :";
	}
	system("pause");
}
long jiecheng(int n)
{
	if(n==0)
		return 1;
	else 
		return n=n*jiecheng(n-1);
}

 

 


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注