Advertisement
damesova

Center Point

Feb 17th, 2019
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class _02_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.         if (findDiagonal(x1, y1) <= findDiagonal(x2, y2)){
  13.             System.out.printf("(%d, %d)", x1, y1);
  14.         } else {
  15.             System.out.printf("(%d, %d)", x2, y2);
  16.         }
  17.     }
  18.  
  19.     private static double findDiagonal(int x, int y){
  20.         double a = x * 1.0;
  21.         double b = y * 1.0;
  22.  
  23.         return Math.sqrt(Math.abs((Math.pow(a, 2)) + (Math.pow(b, 2))));
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement