Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2016
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int x[3], y[3];
  6.  
  7. bool is_between(int a, int b, int c) {
  8.     return min(a, b) <= c && c <= max(a, b);
  9. }
  10.  
  11. bool f(int i, int j, int k) {
  12.     return (x[k] == x[i] || x[k] == x[j]) && is_between(y[i], y[j], y[k]) ||
  13.            (y[k] == y[i] || y[k] == y[j]) && is_between(x[i], x[j], x[k]);
  14. }
  15.  
  16. int main() {
  17.     for (int i = 0; i < 3; i++) {
  18.         cin >> x[i] >> y[i];
  19.     }
  20.  
  21.     if (x[0] == x[1] && x[1] == x[2] || y[0] == y[1] && y[1] == y[2]) {
  22.         cout << "1\n";
  23.     } else if (f(0, 1, 2) || f(0, 2, 1) || f(1, 2, 0)) {
  24.         cout << "2\n";
  25.     } else {
  26.         cout << "3\n";
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement