首页 > 代码库 > 爬楼梯

爬楼梯

#include "stdafx.h"
#include "iostream"
using namespace std;

int fibonacci(int n)
{
if (n > 2)
return fibonacci(n - 1) + fibonacci(n - 2);
else
return 1;
}
int main()
{
int data[20];
int t;
int i;
cin>>"Please input T and the nums: \n";
cin>>"%d",&t;
for (i = 0; i<t; i++)
{
cin>>"%d", &data[i];
}
cout<<"The output: \n";
for (i = 0; i<t; i++)
{
cout<<"%d\n", fibonacci(data[i] + 1);
}
return 0;
}

爬楼梯