#include <iostream>
using namespace std;
long Jiecheng(int );
int main()
{
cout<<"请输入一个整数:"<<endl;
int number;
while (cin>>number)
{
long result = Jiecheng(number);
cout<<"阶乘 "<<number<<"! ="<<result<<endl;
cout<<"请继续输入一个整数:"<<endl;
}
system("pause");
}
long Jiecheng(int n)
{
if (n == 0)
{
return 1;
}
else
return n = n*Jiecheng(n-1);
}
C++primer plus第六版课后编程题答案7.5
最新推荐文章于 2021-01-11 19:31:04 发布