Baekjoon

[#1085] 직사각형에서 탈출

강람이 2020. 3. 8. 16:54
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int x, y, w, h;
    cin >> x >> y >> w >> h;
 
    int minDistance = 1001;
 
    minDistance = min(minDistance, h - y); //위
    minDistance = min(minDistance, y); //아래
    minDistance = min(minDistance, w - x); //오른쪽
    minDistance = min(minDistance, x); //왼쪽
 
    cout << minDistance;
 
    return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

 

최소값만 구하면 되는 문제