Advertisement
CR7CR7

center point

Oct 12th, 2022
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CenterPoint {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int x1 = Integer.parseInt(scanner.nextLine());
  8.         int y1 = Integer.parseInt(scanner.nextLine());
  9.         int x2 = Integer.parseInt(scanner.nextLine());
  10.         int y2 = Integer.parseInt(scanner.nextLine());
  11.  
  12.         closestPoint(x1, x2, y1, y2);
  13.     }
  14.  
  15.     public static void closestPoint(int x1, int x2, int y1, int y2) {
  16.         double firstLine = Math.sqrt( (Math.pow(x1,2) + Math.pow(y1,2) ));
  17.         double secondLine = Math.sqrt( (Math.pow(x2,2) + Math.pow(y2,2) ));
  18.  
  19.         if (firstLine < secondLine)
  20.             System.out.printf("(%d, %d)", x1, y1);
  21.         else
  22.             System.out.printf("(%d, %d)", x2, y2);
  23.         }
  24.     }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement