Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class probd {
  4.  
  5.     public static void main(String args[]) throws IOException {
  6.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  7.         String line = br.readLine();
  8.         String[] xy = line.split(" ");
  9.         int x1 = Integer.parseInt(xy[0]);
  10.         int y1 = Integer.parseInt(xy[1]);
  11.        
  12.         while(x1 >= 0){
  13.             line = br.readLine();
  14.             xy = line.split(" ");
  15.             int x2 = Integer.parseInt(xy[0]);
  16.             int y2 = Integer.parseInt(xy[1]);
  17.            
  18.             line = br.readLine();
  19.             xy = line.split(" ");
  20.             int x3 = Integer.parseInt(xy[0]);
  21.             int y3 = Integer.parseInt(xy[1]);
  22.            
  23.             double m = (y1 - y2)/(x1 - x2);
  24.            
  25.             double a = m;
  26.             double b = -1;
  27.             double c = - m * x1 + y1;
  28.            
  29.             if(a * x3 + b * y3 + c == 0){
  30.                 System.out.println("Em cima do muro.");
  31.             }
  32.             else if(a * x3 + b * y3 + c > 0){
  33.                 System.out.println("Direita!");
  34.             }
  35.             else {
  36.                 System.out.println("Esquerda!");
  37.             }
  38.            
  39.             line = br.readLine();
  40.             xy = line.split(" ");
  41.             x1 = Integer.parseInt(xy[0]);
  42.             y1 = Integer.parseInt(xy[1]);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement