Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Arrays;
  3. import java.util.Scanner;
  4.  
  5. public class kur {
  6.  
  7.     static String closestToCenterCheck (int x1, int y1, int x2, int y2) {
  8.  
  9.         String closest = "";
  10.        
  11.         int firstPoint = Math.abs(x1) + Math.abs(y1);
  12.         int secondPoint = Math.abs(x2) + Math.abs(y2);
  13.  
  14.  
  15.         if (firstPoint < secondPoint) {
  16.             closest += x1 + ", " + y1;
  17.         }else if(firstPoint  > secondPoint) {
  18.             closest += x2 + ", " + y2;
  19.         }else {
  20.             closest += x1 + ", " + y1;
  21.         }
  22.  
  23.         return closest;
  24.     }
  25.  
  26.  
  27.  
  28.     public static void main(String[] args) {
  29.  
  30.         Scanner sc = new Scanner(System.in);
  31.  
  32.         int x1 = Integer.parseInt(sc.nextLine());
  33.         int y1 = Integer.parseInt(sc.nextLine());
  34.         int x2 = Integer.parseInt(sc.nextLine());
  35.         int y2 = Integer.parseInt(sc.nextLine());
  36.  
  37.         System.out.println("(" + closestToCenterCheck(x1, y1, x2, y2) + ")");
  38.  
  39.  
  40.  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement