반응형

 

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int w = scan.nextInt();
		int h = scan.nextInt();
		
		System.out.println(Math.min((x <= w/2) ? x : w-x, (y <= h/2) ? y : h-y));
	}
}

 

부등호를 <= 로 한 이유는 w나 h가 홀수일 경우 소숫점이 버림되어 <, > 로만 했을 때 정상처리가 되지 않기 때문입니다.

반응형
반응형