题库 / 3081208. 当输入 6 时,下列程序的输出结果为(2025-12)
3081208. 当输入 6 时,下列程序的输出结果为(2025-12)
题目描述
当输入 6 时,下列程序的输出结果为()。
#include <iostream>
using namespace std;
int f(int n) {
if (n <= 3) return n;
return f(n - 1) + f(n - 2) + 2 * f(n - 3);
}
int main() {
int n;
cin >> n;
cout << f(n) << endl;
return 0;
}
作答说明
单选题:在选项里选出唯一正确的一项,提交后立即判定。答对得满分,答错可以重新提交(两次提交之间需要间隔 20 秒)。
题目来源
CCF GESP 2025 年 12 月认证 C++ 8 级试题,第 12 题。