code/homework_11.22(1).cpp

28 lines
389 B
C++
Raw Normal View History

2024-11-22 22:58:35 +08:00
#include<iostream>
#include<windows.h>
using namespace std;
int main(){
2024-11-23 08:50:34 +08:00
int tree,wn = 0,clim = 3,time = 0;
cin >> tree;
2024-11-22 22:58:35 +08:00
while (wn < tree)
{
wn += clim;
time ++;
if (wn >= tree)
{
break;
}
2024-11-23 08:50:34 +08:00
wn--;
2024-11-22 22:58:35 +08:00
time++;
}
2024-11-23 08:50:34 +08:00
cout <<"需要"<<time<<" 分钟才能爬到树顶"<<endl;
2024-11-22 22:58:35 +08:00
return 0;
}