对于下面所示的代码,我没有得到响应;在没有任何条件的情况下,我将它保持在最小的位置,例如,想象人们会选择正数。除了以下内容外,我并没有回应:
返回的
进程-1073741571 (0xC00000FD)执行时间: 3.194秒
如果我输入5,答案应该是120,而不是这里。
#include <stdio.h>
#include <stdlib.h>
int faktorijel(int x) {
return (x*faktorijel(x-1));
}
main() {
int a,b;
printf("Type in a number:");
scanf("%d\n", &a);
b=faktorijel(a);
printf("Result is %d\n", b);
return 0;
}发布于 2020-08-17 06:44:26
您应该设置停止if
int faktorijel(int x){
if (x == 1) {
return 1;
} else {
return (x*faktorijel(x-1));
}
}https://stackoverflow.com/questions/63445770
复制相似问题