第30932题 单选题
以下C++代码运行后输出的结果是?
#include <iostream>
#include <cstring>
using namespace std;
const int MAX = 100;
int memo[MAX];

int f(int n) {
    if (n <= 2) return 1;
    if (memo[n] != -1) return memo[n];
    return memo[n] = f(n-1) + f(n-2);
}

int main() {
    memset(memo, -1, sizeof(memo));
    cout << f(6) << endl;
    return 0;
}
A

8

B

13

C

21

D

34

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析