csansoon

P1.09 P89265 Intervals (3)

Sep 19th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 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.    
  29.     if (x1==x2 && y1==y2) {
  30.         cout << "= , ";
  31.     }
  32.     else if (x1>=x2 && y1<=y2) {
  33.         cout << "1 , ";
  34.     }
  35.     else if (x1<=x2 && y1>=y2)  {
  36.         cout << "2 , ";
  37.     }
  38.     else {
  39.         cout << "? , ";
  40.     }
  41.    
  42.     if (x<=y) {
  43.         cout << "[" << x << "," << y << "]" << endl;
  44.     }
  45.     else {
  46.         cout << "[]" << endl;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment