猿问

C语言的阶乘错在哪里了?

#include <stdio.h>

int jc(int n){

int result;

if(n < 0){

printf("输入错误\n");


return 0;


}else if(0 == n || 1 == n){

result 1;


}else {

result = jc(n-1)*n;


return result;


}


int main (){

int n = 5;

printf("阶乘结果: %d\n",n,jc(n));

return 0;

}


慕瓜9113112
浏览 950回答 1
1回答

qq_半夏流年_0

#include <stdio.h>int jc(int n){int result;if(n < 0){printf("输入错误\n");return 0;}else if(0 == n || 1 == n){return 1;}else {result = jc(n-1)*n;} return result;}int main (){int n = 5;printf("阶乘结果: %d\n",jc(n));return 0;}
随时随地看视频慕课网APP
我要回答