Guest User

Untitled

a guest
Oct 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. class Point{
  2. public:
  3. int x, y;
  4. Point(){x = y = 0;}
  5. void make_point(int X, int Y){ x = X; y = Y; }
  6. int Point:: orientation (Point &p0, Point &p1){
  7. Point p2 = *this;
  8. Point a = p1 - p0;
  9. Point b = p2 - p0;
  10. int area = (a.x * b.y) - (b.x * a.y);
  11. if (area > 0)return 1;
  12. if (area < 0)return -1;
  13. return 0;
  14. }
  15. };
  16. int main() {
  17. Point p[4];
  18. p[0].make_point(0, 0);
  19. p[1].make_point(0, 1);
  20. p[2].make_point(1, 1);
  21. p[3].make_point(1, 0);
  22. int sz = sizeof(p) / sizeof(p[0]);
  23. int ans = 0;
  24. for (int i = 0; i < sz; i++){
  25. for (int j = i+1; j < sz; j++){
  26. int leftCnt = 0, rightCnt = 0;
  27. for (int k = 0; k < sz; k++){
  28. if (k == i || k == j)continue;
  29. if (p[k].orientation(p[i], p[j]) == 1)leftCnt++;
  30. if (p[k].orientation(p[i], p[j]) == -1)rightCnt++;
  31. }
  32. if (leftCnt == rightCnt && leftCnt == (sz/2-1))ans++;
  33. }
  34. }
  35. cout << ans << 'n';
  36.  
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment