阶乘顺序问题
#include <stdio.h>
int sum(int i)
{
int result;
if(i<0)
{
printf("%s\n","输入错误!");
return 0;
}
else if(i==0 || i==1)
{
result = 1;
}
else
{
result = i*sum(i-1);
}
printf("%d\n",result);
return result;
}
int main()
{
int i = 5;
printf("和为%d\n",sum(i));
return 0;
}
运行结果
1
2
6
24
120
阶乘顺序为何不是倒着输出?