hanker

백준(1085) JAVA - 직사각형에서 탈출 본문

Study/ALGORITHM

백준(1085) JAVA - 직사각형에서 탈출

hanker 2021. 6. 25. 09:34
반응형
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        int w = sc.nextInt();
        int h = sc.nextInt();

        int xLen = Math.min(x, w-x);
        int yLen = Math.min(y, h-y);

        System.out.println(Math.min(xLen, yLen));
    }
}
반응형