#include <bits/stdc++.h> using namespace std; int main(){ int n; int f[12]; f[0]= 0; f[1] = 1; for(int i = 2 ; i<11; i++){ f[i] = f[i-1]*2 + f[i-2]; } while(cin>>n){ cout<<f[n]<<endl; } return 0; }
Double click to view unformatted code.