实现多组输出,但程序的阶乘只能输出最后一个数的
#include<iostream>using namespace std;
int p(int n)
{
if(n==1)
return 1;
else
return n*p(n-1);
}
int main()
{
int K,N;
cin>>K;
if(K>1&&K<10)
{
while(K--)
cin>>N;
cout<<p(N)<<endl;
}
return 0;
}
2015-05-25 21:28

2015-05-25 21:42
2015-05-26 19:27

2015-05-26 19:31