当日总结
跳台阶问题
include <bits/stdc++.h>
using namespace std;
int n;
int dg(int dep)
{
if (dep == 1) return 1;
if (dep == 2) return 2; //终止条件
return dg(dep - 1) + dg(dep - 2);
}
int main()
{
scanf("%d", &n);
printf("%d\n", dg(n)); //用递归
return 0;
}

浙公网安备 33010602011771号