csansoon

P1.08 P51126 Intervals (1)

Sep 19th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5.     int x1, y1, x2, y2, x, y;
  6.  
  7.     cin >> x1 >> y1 >> x2 >> y2;
  8.     if (x1<=x2) {
  9.         if (y1<=y2) {
  10.             x=x2;
  11.             y=y1;
  12.         }
  13.         else {
  14.             x=x2;
  15.             y=y2;
  16.         }
  17.     }
  18.     else {
  19.         if (y1<=y2) {
  20.             x=x1;
  21.             y=y1;
  22.         }
  23.         else {
  24.             x=x1;
  25.             y=y2;
  26.         }
  27.     }
  28.     if (x<=y) {
  29.         cout << "[" << x << "," << y << "]" << endl;
  30.     }
  31.     else {
  32.         cout << "[]" << endl;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment