刚学函数,不太懂,求大神指导。帮忙看下下面源码有什么错误呀!
编程:利用递归方法求5!。#include<stdio.h>
int jiecheng(int n)
{
int sum;
sum=n*(jiecheng(n-1));
printf("%d",sum);
return 0;
}
void main()
{
int a;
scanf("%d",&a);
jiecheng(a);
}
#include<stdio.h> int jiecheng(int n) { int sum; if(n ==1 ) return 1; sum=n*(jiecheng(n-1)); return sum; } void main() { int a; int sum; scanf("%d",&a); sum = jiecheng(a); printf("%d\n",sum); }
[此贴子已经被作者于2018-12-17 21:40编辑过]