알고리즘 연습

C++1085 직사각형에서 탈출

728x90

#include <iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int x, y, w, h;
	cin >> x >> y >> w >> h;

	int xmin = 0;
	int ymin = 0;
	int totalmin = 0;

	(x) > (w - x) ? xmin = w - x : xmin = x;
	(y) > (h - y) ? ymin = h - y : ymin = y;

	xmin > ymin ? totalmin = ymin : totalmin = xmin;

	cout << totalmin;

}

코드를 실행시키기 전까지는 뭐가 틀렸는지 인식을 잘 못한다..

728x90

'알고리즘 연습' 카테고리의 다른 글

C++ 2798 블랙잭  (0) 2021.09.30
C++ 4153 직각삼각형  (0) 2021.09.28
C++ 9020 골드바흐의 추측  (0) 2021.09.28
C++ 4948 베르트랑 공준  (0) 2021.09.27
C++ 11653 소인수분해  (0) 2021.09.27