DidiMilikina

06. Point on Rectangle Border

Oct 7th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.     double x1, y1, x2, y2, x, y;
  9.     cin >> x1 >> y1 >> x2 >> y2 >> x >> y;
  10.     bool on_left_side = (x == x1) && (y >= y1) && (y <= y2);
  11.     bool on_right_side = (x == x2) && (y >= y1) && (y <= y2);
  12.     bool on_up_side = (y == y1) && (x >= x1) && (x <= x2);
  13.     bool on_down_side = (y == y2) && (x >= x1) && (x <= x2);
  14.     if (on_left_side || on_right_side || on_up_side || on_down_side) {
  15.         cout << "Border" << endl;
  16.     }
  17.     else {
  18.         cout << "Inside / Outside" << endl;
  19.     }
  20.  
  21. }
Add Comment
Please, Sign In to add comment