下面代码采用递推算法来计算斐波那契数列f(n)=f(n-1)+f(n-2),则横线上应填写( )。
1 int fib(int n) { 2 if (n == 0 || n == 1) 3 return n; 4 5 int f1 = 0; 6 int f2 = 1; 7 int result = 0; 8 for (int i = 2; i <= n; i++) { 9 ________________________________ // 在此处填入代码 10 } 11 return result; 12 }
1 result = f1 + f2; 2 f1 = f2; 3 f2 = result;
1 result += f1 + f2;
2 f1 = f2;
3 f2 = result;
1 result += f1 + f2; 2 f2 = result; 3 f1 = f2;
1 result = f1 + f2; 2 f2 = result; 3 f1 = f2;