Advertisement
CosmicFox33

triangle and point

Feb 28th, 2022
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct point{
  5.     double x,y;
  6. } A, B, C, D;
  7.  
  8. double s1, s2, s3, s;
  9.  
  10. double sqr(double x) {
  11.     return x*x;
  12. }
  13.  
  14. double dist(point A, point B){
  15.     return sqrt(sqr(B.x-A.x)+sqr(B.y-A.y));
  16. }
  17.  
  18. double tr(point A, point B, point C){
  19.     double a,b,c,p;
  20.     a=dist(A,B);
  21.     b=dist(B,C);
  22.     c=dist(A,C);
  23.     p=(a+b+c)/2;
  24.     return sqrt(p*(p-a)*(p-b)*(p-c));
  25. }
  26.  
  27. int main()
  28. {
  29.     cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;
  30.  
  31.     s=tr(A,B,C);
  32.     s1=tr(A,B,D);
  33.     s2=tr(B,C,D);
  34.     s3=tr(A,C,D);
  35.  
  36.     cout << ((s>s1+s2+s3-0.0001)?"In":"Out");
  37.  
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement