0
This commit is contained in:
parent
d2b0ed7908
commit
4dc7afa499
26
homework_11.22(1).cpp
Normal file
26
homework_11.22(1).cpp
Normal 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
21
homework_11.22(2).cpp
Normal 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.
Loading…
x
Reference in New Issue
Block a user