标签:++ return using stat int ati 爬楼梯 ace pac
问题:一老师爬楼梯,楼梯有n阶,一次只能走1阶或2阶,请问有几种走法?
#include <iostream> using namespace std; int fun(int a) { static int i = 0; if(a==0||a==1) return 1; return fun(a-1)+fun(a-2); } int main() { int a = 4; cout<<fun(a)<<endl; return 0; }
运行结果:
5
标签:++ return using stat int ati 爬楼梯 ace pac
原文地址:https://www.cnblogs.com/caozewen/p/12207894.html