This commit is contained in:
Dengrb 2024-11-22 22:58:35 +08:00
parent d2b0ed7908
commit 4dc7afa499
3 changed files with 47 additions and 0 deletions

26
homework_11.22(1).cpp Normal file
View File

@ -0,0 +1,26 @@
#include<iostream>
#include<windows.h>
using namespace std;
int main(){
int tree = 17,wn = 0,clim = 3,down = 1,time = 0;
while (wn < tree)
{
wn += clim;
time ++;
if (wn >= tree)
{
break;
}
wn -= down;
time++;
}
cout <<time<<endl;
return 0;
}

21
homework_11.22(2).cpp Normal file
View File

@ -0,0 +1,21 @@
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int n;
cin >> n;
double sum = 0.0;
for (int i = 1; i <= n; ++i)
{
sum += 1.0 / i;
}
cout <<fixed<<setprecision(3)<<sum<<endl;
return 0;
}

Binary file not shown.