我正试图展示攀登第n个楼梯的可能性。 在C ++中,除了这些功能,如果您能提供帮助,我将非常感谢。
#include<iostream>
using namespace std;
class stairCase{
public: int staircase(int m){
if(m==1 || m==0)
{
return 1;
}
else
return staircase (m - 2) + staircase (m - 1);
}
};
class CountStairs:public stairCase{
int StairsNum;
public:void input(){
cout<<"Enter number of stairs"<<endl;
cin>>StairsNum;
}
void Counter() {
cout<<"No of ways to climb stairs are ";
cout<<staircase(StairsNum)<<endl;
}
};
int main(){
CountStairs count;
count.input();
count.Counter();
return 0;
}