#include <iostream>
using namespace std;
int fac(int);
int main()
{
int a,b,c;
cout<<"please enter a,b,c";
cin>>a>>b>>c;
cout<<"a!="<<fac(a)<<","<<"b!="<<fac(b)<<","<<"c!="<<fac(c)<<endl;
system("pause");
return 0;
}
int fac(int x)
{
int y;
if (x<0)
{
cout<<"error!"<<endl;
y=-1;
}
else if(x==0 || x==1)y=1;
else y=fac(x-1)*x;
return y;
}
原文地址:https://www.cnblogs.com/Eternal-kong/p/8417047.html
时间: 2024-10-10 02:17:31