View Code of Problem 60

#include<iostream>

using namespace std;

int num[50];

int add(int n){
    if(n<=0){
        return 0;
    }
    if(n==1){
        return 2;
    }
    if(n==2){
        return 3;
    }
    else{
        return add(n-1)+add(n-2);
    }
}
int main(void){
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    for(int e=1;e<=T;e++){
        int n;
        cin >> n;
        int sum=add(n);
        cout << "Scenario #" << e << ":" << endl;
        cout << sum << endl;
    }
}

Double click to view unformatted code.


Back to problem 60