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);
}


posted @ 2014-04-08 16:47  天下纵横C++  阅读(217)  评论(0编辑  收藏  举报