#include<stdio.h>
int main()
{
int jiecheng(int n);
int n;
scanf("%d",&n);
if(n<0)
{
printf("error!\n");
return 0;
}
else
printf("%d!=%d\n",n,jiecheng(n));
return 0;
}
int jiecheng(int n)
{
int jieguo;
if(n==0||n==1)
jieguo = 1;
else
jieguo = jiecheng(n-1) * n;
return(jieguo);
}
/*vc++6.0:
5
5!=120
Press any key to continue
0
0!=1
Press any key to continue
-8
error!
Press any key to continue
*/
C语言函数递归:求n!
最新推荐文章于 2023-11-20 23:57:35 发布