import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
int w = Integer.parseInt(st.nextToken());
int h = Integer.parseInt(st.nextToken());
br.close();
int minX = x > (w - x) ? (w - x) : x;
int minY = y > (h - y) ? (h - y) : y;
System.out.println(minX > minY ? minY : minX);
}
}
Math.min()
을 이용하여 풀이도 가능하다.
하지만 삼항연산자가 더 빨라서 삼항연산자를 채택하였다.