爬楼梯
#include "stdafx.h"
#include<iostream>
using namespace std;
int method(int a)
{ if (a==1)
return 1;
else
if (a==2)
return 2;
else
if (a>2)
return method(a-1)+method(a-2);
}
int _tmain(int argc, _TCHAR* argv[])
{
int floor,a;
cout <<"请输入楼层;"<<endl;
cin>>floor;
cout<<"方法数为:"<<method(floor)<<endl;
return 0;
}