输入x,输出1到x的阶乘
#include <iostream> //求出1~n的阶乘
using namespace std;
int digui(int n);
int main()
{
int x, i;
cin >> x;
for (i = 1; i <= x; i++)
{
cout << digui(i)<<endl;
}
system("pause");
return 0;
}
int digui(int n)
{
int t;
if (n == 1)
t = 1;
else
t = n * digui(n - 1);
return t; //t和main()中i无需一致,随便一个名字即可
}