Advertisement
Toliak

yep111

Oct 4th, 2018
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     double epsilon;
  6.     cout << "vvedite Epsilon: " << endl;
  7.     cin >> epsilon;
  8.     unsigned long i1 = 0;
  9.     unsigned long i2 = 0;
  10.     double v1 = 4., v2 = 3.;
  11.     unsigned long ii1 = 0, ii2 = 0;
  12.     while (true)
  13.     {
  14.         double current = v1 + 4 * (i1 % 2 == 0 ? -1 : 1) * (1. / (3 + 2 * i1));
  15.         i1++;
  16.         if (ii1 < 10) {
  17.             cout << "value 1 " << current << endl;
  18.             ii1++;
  19.         }
  20.         if (fabs(current - v1) < epsilon) {
  21.             v1 = current;
  22.             break;
  23.         }
  24.         v1 = current;
  25.     }
  26.     while (true)
  27.     {
  28.         double current = v2 + 4 * (i2 % 2 == 0 ? 1 : -1) * (1. / (
  29.             (i2 + 2)*(i2 + 3)*(i2 + 4)
  30.             ));
  31.         i2++;
  32.         if (ii2 < 10) {
  33.             cout << "value 2 " << current << endl;
  34.             ii2++;
  35.         }
  36.         if (fabs(current - v2) < epsilon) {
  37.             v2 = current;
  38.             break;
  39.         }
  40.         v2 = current;
  41.     }
  42.     cout << "cicl 1 : " << i1 << endl;
  43.     cout << "cicl 2: " << i2 << endl << endl;
  44.     cout << "ZNACHENIYA" << endl;
  45.     cout << "1: " << v1 << endl;
  46.     cout << "2: " << v2 << endl << endl;
  47.     if (i1 > i2)
  48.     {
  49.         cout << "Cicl 2 bistree" << endl << endl;
  50.     }
  51.     else
  52.     {
  53.         cout << "cicl 1 bistree" << endl << endl;
  54.     }
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement