int fact(int n) {
int result;
if (n == 1) return 1; //n=1;函数返回值是1
result = fact(n-1) * n; //得到fact(n-1)的返回值并*n
return result;
}
fact(4) = fact(3)*4;
fact(3) = fact(2)*3;
fact(2) = fact(1)*2;
fact(1) = 1;
int result;
if (n == 1) return 1; //n=1;函数返回值是1
result = fact(n-1) * n; //得到fact(n-1)的返回值并*n
return result;
}
fact(4) = fact(3)*4;
fact(3) = fact(2)*3;
fact(2) = fact(1)*2;
fact(1) = 1;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货