第20453题 单选
以下C++递推实现斐波那契数列的代码中,横线处应填入的正确代码是?

下面代码采用递推算法来计算斐波那契数列$f(n)=f(n-1)+f(n-2)$,则横线上应填写的内容是:

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;