Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Arrays;
- import java.util.Scanner;
- public class kur {
- static String closestToCenterCheck (int firstX, int firstY, int secondX, int secondY) {
- String closest = "";
- int absFirstX = Math.abs(firstX);
- int absFirstY = Math.abs(firstY);
- int absSecondX = Math.abs(secondX);
- int absSecondY = Math.abs(secondY);
- if (absFirstX + absFirstY < absSecondX + absSecondY) {
- closest += firstX + ", " + firstY;
- }else if(absFirstX + absFirstY > absSecondX + absSecondY) {
- closest += secondX + ", " + secondY;
- }else {
- closest += firstX + ", " + firstY;
- }
- return closest;
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int firstX = Integer.parseInt(sc.nextLine());
- int firstY = Integer.parseInt(sc.nextLine());
- int secondX = Integer.parseInt(sc.nextLine());
- int secondY = Integer.parseInt(sc.nextLine());
- System.out.println("(" + closestToCenterCheck(firstX, firstY, secondX, secondY) + ")");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement