baekjoon 1085

0_23·2022년 12월 5일
0

[BOJ][Java]

목록 보기
47/55
post-thumbnail

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringTokenizer st = new StringTokenizer(br.readLine());
        int x = Integer.parseInt(st.nextToken()), y = Integer.parseInt(st.nextToken()), w = Integer.parseInt(st.nextToken()), h = Integer.parseInt(st.nextToken()), wx=0,hy=0;
        if((w-x)>(x-0))
            wx = x-0;
        else
            wx = w-x;
        if((h-y)>(y-0))
            hy = y-0;
        else
            hy = h-y;
        if (wx>hy)
            sb.append(hy);
        else
            sb.append(wx);
        System.out.println(sb);
    }
}

0개의 댓글