主题:用类求N!怎么改啊???我刚学不会写
#include"iostream"
using namespace std;
class A
{private:
int x;
public:
int a(int b)
{
if(b<0)
cout<<"输入有误"<<endl;
else
if((b==0)||(b==1))return 1;
else
return a(b-1)*b;
}
};
void main()
{int a(n);
cin>>n;
A function_test;
n=function_test.a(10);
cout<<n<<endl;
}
using namespace std;
class A
{private:
int x;
public:
int a(int b)
{
if(b<0)
cout<<"输入有误"<<endl;
else
if((b==0)||(b==1))return 1;
else
return a(b-1)*b;
}
};
void main()
{int a(n);
cin>>n;
A function_test;
n=function_test.a(10);
cout<<n<<endl;
}