Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int square(int a1, int a2, int b1, int b2)
  5. {
  6. return (fabs(a1 * b2 - a2 * b1));
  7. }
  8.  
  9. int main()
  10. {
  11. int a1, a2, b1, b2, c1, c2;
  12. int x1, x2;
  13. scanf("%d %d %d %d %d %d", &a1, &a2, &b1, &b2, &c1, &c2);
  14. scanf("%d %d", &x1, &x2);
  15.  
  16. int right_answer = square (b1 - a1, b2 - a2, c1 - a1, c2 - a2);
  17. int check_answer = square (b1 - a1, b2 - a2, x1 - a1, x2 - a2);
  18. check_answer += square (c1 - b1, c2 - b2, x1 - b1, x2 - b2);
  19. check_answer += square (a1 - c1, a2 - c2, x1 - c1, x2 - c2);
  20.  
  21. if (right_answer == 0 && check_answer == 0)
  22. {
  23. if (sqrt((x1 - a1) * (x1 - a1) + (x2 - a2) * (x2 - a2)) + sqrt((x1 - b1) * (x1 - b1) + (x2 - b2) * (x2 - b2)) == sqrt((b1 - a1) * (b1 - a1) + (b2 - a2) * (b2 - a2)))
  24. {
  25. printf("In");
  26. return 0;
  27. }
  28. if (sqrt((x1 - a1) * (x1 - a1) + (x2 - a2) * (x2 - a2)) + sqrt((x1 - c1) * (x1 - c1) + (x2 - c2) * (x2 - c2)) == sqrt((c1 - a1) * (c1 - a1) + (c2 - a2) * (c2 - a2)))
  29. {
  30. printf("In");
  31. return 0;
  32. }
  33. if (sqrt((x1 - b1) * (x1 - b1) + (x2 - b2) * (x2 - b2)) + sqrt((x1 - c1) * (x1 - c1) + (x2 - c2) * (x2 - c2)) == sqrt((c1 - b1) * (c1 - b1) + (c2 - b2) * (c2 - b2)))
  34. {
  35. printf("In");
  36. return 0;
  37. }
  38. printf("Out");
  39. return 0;
  40. }
  41.  
  42. if (check_answer == right_answer)
  43. printf("In");
  44. else
  45. printf("Out");
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement