标签:
https://leetcode.com/problems/climbing-stairs/
1 class Solution { 2 public: 3 int climbStairs(int n) { 4 if(n==1) 5 return 1; 6 else if(n==2) 7 return 2; 8 else if(n>2) 9 { 10 int* nums=new int[n+1]; 11 nums[1]=1; 12 nums[2]=2; 13 for(int i=3;i<=n;i++) 14 { 15 nums[i]=nums[i-1]+nums[i-2]; 16 } 17 return nums[n]; 18 } 19 else 20 return 0; 21 } 22 };
标签:
原文地址:http://www.cnblogs.com/aguai1992/p/4641069.html