알고리즘 문제
[백준] 1085번 직사각형에서 탈출
feelcoding
2020. 2. 2. 00:13
728x90
1085번: 직사각형에서 탈출
첫째 줄에 x y w h가 주어진다. w와 h는 1,000보다 작거나 같은 자연수이고, x는 1보다 크거나 같고, w-1보다 작거나 같은 자연수이고, y는 1보다 크거나 같고, h-1보다 작거나 같은 자연수이다.
www.acmicpc.net
#include <iostream>
using namespace std;
int main() {
int x, y, w, h;
cin >> x >> y >> w >> h;
int minWidth = (w - x > x) ? x : w - x;
int minHeight = (h - y > y) ? y : h - y;
cout << ((minWidth > minHeight) ? minHeight : minWidth);
return 0;
}
728x90