I. [GESP]L4-202412-Q2816-S
[GESP]L4-202412-Q2816-S
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
下面代码采用递推算法来计算斐波那契数列 ,则横线上应填写( )。
int fib(int n) {
if (n == 0 || n == 1)
return n;
int f1 = 0;
int f2 = 1;
int result = 0;
for (int i = 2; i <= n; i++) {
// 在此处填入代码
}
return result;
}
A.
result = f1 + f2;
f1 = f2;
f2 = result;
B.
result += f1 + f2;
f1 = f2;
f2 = result;
C.
result += f1 + f2;
f2 = result;
f1 = f2;
D.
result = f1 + f2;
f2 = result;
f1 = f2;
{{ select(1) }}
- A
- B
- C
- D
GESP 2024.12 C++ 四级 全真模拟赛
- 状态
- 已结束
- 规则
- OI
- 题目
- 27
- 开始于
- 2026-11-20 13:31
- 结束于
- 2026-11-25 13:31
- 持续时间
- 2 小时
- 主持人
- 参赛人数
- 0