以下是代码:
#include "stdio.h"
int jiecheng(int x)
{
if(x<0)
return 0;
if(0==x||1==x)
return 1;
return jiecheng(x-1)*x;
}
int main()
{
int m,n,t;
printf("输入m的值:",m);
scanf("%d",&m);
t=jiecheng(m);
if(0==t)
printf("%d的值输入有误!\n",m);
else
printf("%d! = %d\n",m,t);
printf("输入n的值:",n);
scanf("%d",&n);
t=jiecheng(n);
if(0==t)
printf("%d的值输入有误!\n",n);
else
printf("%d! = %d\n",n,t);
return 0;
}