Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <vector>
- using namespace std;
- void f(float a, float b, float c) {
- float e = 0.000001;
- ofstream out("output.txt");
- vector<float> vx, vn, vs;
- int count = 0;
- for (float x = a; x <= b; x += c) {
- float slag = (7 * x);
- int k = 1;
- float res = slag;
- int deg = 1;
- while (abs(slag) >= e) {
- deg = 2 * k + 1;
- slag *= -(49 * x * x);
- slag /= (deg * (deg - 1));
- k++;
- res += slag;
- }
- vx.push_back(x);
- vs.push_back(res);
- vn.push_back(k);
- count++;
- }
- //*************НАЧАЛО ВТОРОГО ЗАДАНИЯ******************
- out << "x = ";
- for (int i = 0; i < count; i++)
- out << setw(10) << vx[i];
- out << endl;
- out << "n = ";
- for (int i = 0; i < count; i++)
- out << setw(10) << vn[i];
- out << endl;
- out << "f = ";
- for (int i = 0; i < count; i++)
- out << setw(10) << vs[i];
- out << endl;
- vector<float> vnx, vns;
- for (int i = 0; i < count; i++) {
- vnx.push_back(vx[i]);
- if(vx[i] != vx[count - 1])
- vnx.push_back((vx[i] + vx[i + 1]) / 2);
- }
- for (int i = 0; i < count; i++) {
- vns.push_back(vs[i]);
- if(vs[i] != vs[count - 1])
- vns.push_back((vs[i] + vs[i + 1]) / 2);
- }
- out << "x = ";
- for (int i = 0; i < count * 2 - 1; i++)
- out << setw(10) << vnx[i];
- out << endl;
- out << "g1 = ";
- for (int i = 0; i < count * 2 - 1; i++)
- out << setw(10) << vns[i];
- out << endl;
- //**********НАЧАЛО 3 ЗАДАНИЯ*************
- vector<float> v2s;
- for (int i = 0; i < count * 2 - 1; i++) {
- v2s.push_back(vs[i]);
- float chis = 1, znam = 1;
- float L = 0;
- if(vx[i] != vx[count - 1]) {
- for (int j = 0; j < count; j++)
- chis *= (vnx[i + 1] - vx[i]
- v2s.push_back((vx[i] + vx[i + 1]) / 2);
- }
- out.close();
- }
- int main() {
- float a, b;
- float c;
- cout << "a = ";
- cin >> a;
- cout << "b = ";
- cin >> b;
- cout << "c = ";
- cin >> c;
- f(a,b,c);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement