Advertisement
Risonna

lab2_n5

Oct 27th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     float x, y, s;
  8.     cout << "x="; cin >> x;
  9.     cout << "y="; cin >> y;
  10.     if (x != y)
  11.     {
  12.         if (y > x)
  13.         {
  14.             s = y;
  15.             y = y * x * 2;
  16.             x = (x + s) * 0.5;
  17.         }
  18.         else
  19.         {
  20.             s = x;
  21.             x = y * x * 2;
  22.             y = (s + y) * 0.5;
  23.         }
  24.     }
  25.     else
  26.     {
  27.         cout << "x=y, действия не имеют смысла\n";
  28.     }
  29.     cout << "x=" << x << "\n";
  30.     cout << "y=" << y << "\n";
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement