?? template.cpp
字號:
//============================
//程序名稱: .cpp
//程序描述:
//作者:
//日期:
//版本號: V0.0.1
//============================
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> a(40, 1); // 需要最前面加上#include<vector>
// 計算所有的f(n),注意f(n)的值放在a[n-1]中
for (int i = 3; i < 40; ++i)
{
a[i] = a[i - 1] + a[i - 3];
}
// 邊讀入n,邊對a進行下標訪問,獲得f(n)
for (int n; cin >> n;)
{
cout << a[n - 1] << "\n";
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -