fork(4) download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. float f (float x, float x0, float x1, float y, float y0, float y1)
  5. {
  6. return (x - x0) * (y1 - y0) - (y - y0) * (x1 - x0);
  7. }
  8. int main() {
  9. float xa, ya, xb, yb, xc, yc, xd, yd,xk,yk;
  10. xa = -1;
  11. ya = 0;
  12. xb = 0;
  13. yb = 1;
  14. xc = 1;
  15. yc = 0;
  16. xd = 0;
  17. yd = -1;
  18. cin >> xk >> yk;
  19. float l,m,q,w;
  20. l = f(xk,xa,xb,yk,ya,yb);
  21. m = f(xk,xb,xc,yk,yb,yc);
  22. q = f(xk,xc,xd,yk,yc,yd);
  23. w = f(xk,xd,xa,yk,yd,ya);
  24. if ((l >= 0) && (m >= 0) && (q >= 0) && (w >= 0))
  25. {
  26. printf ("inside");
  27. }
  28. else
  29. printf ("outside");
  30. return 0;
  31. }
Success #stdin #stdout 0s 3476KB
stdin
-0.1 0.9
stdout
inside