标签:nbsp using name 台阶 运行 iostream while solution ber
1 #include <iostream> 2 using namespace std; 3 class Solution { 4 public: 5 //fn=2^(n-1) 6 int jumpFloorII(int number) { 7 if(number <= 0) 8 return 0; 9 //fibN = 2^(n-1); 10 else if(number == 1) 11 return 1; 12 else 13 return 2*jumpFloorII(number-1); 14 15 } 16 }; 17 int main() 18 { 19 int n; 20 while(cin>>n) 21 { 22 Solution s; 23 cout<<"跳"<<n<<"级台阶需要步数:"<<s.jumpFloorII(n)<<endl; 24 } 25 return 0; 26 }
程序运行结果截图:
标签:nbsp using name 台阶 运行 iostream while solution ber
原文地址:http://www.cnblogs.com/qqky/p/6829263.html