include<stdio.h>
include<stdlib.h>
int fac(int n)
{
if (n <= 1)
{
return 1;
}
else
{
return n*fac(n - 1);
}
}
int main()
{
int i = 0;
int n = 0;
printf("请输入一个数\n");
scanf("%d", &n);
int ret = fac(n);
printf("%d\n", ret);
system("pause");
return 0;
}
递归实现N的阶乘
最新推荐文章于 2024-09-04 00:37:27 发布