Advertisement
ULK

Д. М. Златопольский (10.3.)

ULK
May 15th, 2023
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. //без функции max
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a, b, z;
  8.     int max1, max2;
  9.     cout << "Enter the numbers a & b: \n";
  10.     cin >> a >> b;
  11.  
  12.     if (a > 2 * b) {
  13.         max1 = a;
  14.     }
  15.     else {
  16.         max1 = 2 * b;
  17.     }
  18.  
  19.     if (2*a-b > b) {
  20.         max2 = 2 * a - b;
  21.     }
  22.     else {
  23.         max2 = b;
  24.     }
  25.  
  26.     z = max1 * max2;
  27.     cout << "Number z = " << z;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement