fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static double f (double x, double x0, double x1, double y, double y0, double y1){
  11. return (x - x0) * (y1 - y0) - (y - y0) * (x1 - x0);
  12. }
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. double xa, ya, xb, yb, xc, yc, xd, yd,xk,yk;
  16. xa = -0.5;
  17. ya = 0;
  18. xb = 0;
  19. yb = 1;
  20. xc = 0.5;
  21. yc = 0;
  22. xd = 0;
  23. yd = -1;
  24. Scanner in = new Scanner(System.in);
  25. xk = in.nextDouble();
  26. yk = in.nextDouble();
  27. double l,m,q,w;
  28. l = f(xk,xa,xb,yk,ya,yb);
  29. m = f(xk,xb,xc,yk,yb,yc);
  30. q = f(xk,xc,xd,yk,yc,yd);
  31. w = f(xk,xd,xa,yk,yd,ya);
  32. if ((l >= 0) && (m >= 0) && (q >= 0) && (w >= 0)){
  33. System.out.printf("Принадлежит " );
  34. }
  35. else
  36. System.out.printf("Не принадлежит " );
  37. }
  38. }
Success #stdin #stdout 0.16s 321280KB
stdin
0 0
stdout
Принадлежит