当x为偶数时,f(x)=f(x-1)+5;
1 回答
已采纳
皓韵儿
TA贡献86条经验 获得超114个赞
#include <stdio.h>
int f(int x){
if(x == 0)
return 0;
else if(x % 2 == 0){
return f(x - 1) + 5;
}
else {
return f(x - 1) + 3;
}
}
int main(){
int x;
scanf("%d", &x);
int t = f(x);
printf("%d\n", t);
return 0;
}有什么不明白的可以再问我。
- 1 回答
- 0 关注
- 1210 浏览
添加回答
举报
0/150
提交
取消
