View Code of Problem 60

#include<iostream>
#include<string>
using namespace std;



int main()
{
	int n,k,a[40],j=1;
	cin>>n;
	while(n--)
	{
		cin>>k;
		a[0]=2,a[1]=3;
		if(n>2)
		{
			for(int i=2 ;i<k;i++) 
			{
				
				a[i]=a[i-1]+a[i-2];
//				cout<<a[i]<<endl;
			}
			
		}
		cout<<"Scenario #"<<j++<<":"<<endl;
		if(k==0)
		{
			cout<<0<<endl;
		}
		else
			cout<<a[k-1]<<endl;
		
		
	} 
	return 0;
}

Double click to view unformatted code.


Back to problem 60