以下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;
}
正在加载题目数据…
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析