50分求助!!!样例过了的
  • 板块P1255 数楼梯
  • 楼主dongrq_cs
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/4/3 20:20
  • 上次更新2023/10/23 19:31:20
查看原帖
50分求助!!!样例过了的
644394
dongrq_cs楼主2023/4/3 20:20
#include <iostream>
using namespace std;
int step(int n){
	if(n == 1){
		return 1;
	}
	if(n == 2){
		return 2; 
	}
	return step(n - 1) + step(n - 2);
}
int main(){
	int n;
	while(cin >> n && n != 0){
		cout << step(n) << endl;
	}
	return 0;
}
2023/4/3 20:20
加载中...