본문 바로가기

Programming/BaekJoon

[C++] 백준 1085번 : 직사각형에서 탈출


https://www.acmicpc.net/problem/1085




#include <iostream>

using namespace std;

int main(){

    int x,y,w,h;

    cin >> x >> y >> w >> h;

    int dis[4];

    dis[0] = x;

    dis[1] = h-y;

    dis[2] = w-x;

    dis[3] = y;

    int result = dis[0];

    for(int i=0; i<3;i++){

        if(result > dis[i+1])

            result = dis[i+1];

    }

    cout << result << "\n";

    

}