#include<stdio.h>
int main()
{
int fac(int n);
int n,x;
printf("请输入要求阶乘的数:");
scanf("%d",&n);
x=fac(n);
printf("%d的阶乘是:%d\n",n,x);
return 0;
}
int fac(int n)
{
int c;
if(n<0)printf("错误,请重新输入:\n");
else if(n==0||n==1)c=1;
else c=fac(n-1)*n;
return c;
}
int main()
{
int fac(int n);
int n,x;
printf("请输入要求阶乘的数:");
scanf("%d",&n);
x=fac(n);
printf("%d的阶乘是:%d\n",n,x);
return 0;
}
int fac(int n)
{
int c;
if(n<0)printf("错误,请重新输入:\n");
else if(n==0||n==1)c=1;
else c=fac(n-1)*n;
return c;
}