c2
This commit is contained in:
parent
0d75f30a49
commit
4744ebb565
69 changed files with 7 additions and 5 deletions
20
1sem/programming basics/z05/13.cpp
Normal file
20
1sem/programming basics/z05/13.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// pb_z5_13.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
double ai(int);
|
||||
|
||||
int main() {
|
||||
int N;
|
||||
cout << "N >>>";
|
||||
cin >> N;
|
||||
cout << "S= " << ai(N);
|
||||
}
|
||||
|
||||
double ai(int N) {
|
||||
double out = 0;
|
||||
for (int i = 1; i <= N; i++)
|
||||
out += (float)i/((float)i+1.f);
|
||||
return out;
|
||||
}
|
||||
28
1sem/programming basics/z05/14.cpp
Normal file
28
1sem/programming basics/z05/14.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// pb_z5_14.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
double ai(int, double);
|
||||
double spow(double, double);
|
||||
|
||||
int main() {
|
||||
int N;
|
||||
double x;
|
||||
cout << "N, x >>>";
|
||||
cin >> N >> x;
|
||||
cout << "P= " << ai(N, x);
|
||||
}
|
||||
|
||||
double ai(int N, double x) {
|
||||
double out = 1;
|
||||
for (int i = 1; i <= N; i++)
|
||||
out *= 2 * spow(x, i);
|
||||
return out;
|
||||
}
|
||||
|
||||
double spow(double f, double p) {
|
||||
double out = 1;
|
||||
for (int i = 0; i < p; i++) out *= f;
|
||||
return out;
|
||||
}
|
||||
25
1sem/programming basics/z05/15.cpp
Normal file
25
1sem/programming basics/z05/15.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// pb_z5_15.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
double ai(int);
|
||||
double s(int);
|
||||
|
||||
int main() {
|
||||
int N;
|
||||
cout << "N >>>";
|
||||
cin >> N;
|
||||
cout << "S= " << ai(N);
|
||||
}
|
||||
|
||||
double ai(int N) {
|
||||
double out = 0;
|
||||
for (int i = 1; i <= N; i++)
|
||||
out += i * s(i);
|
||||
return out;
|
||||
}
|
||||
|
||||
double s(int i) {
|
||||
return (i % 2? -1 : 1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue