백준 1476번 : 날짜계산

5P2RS5·2022년 6월 22일

백준

목록 보기
5/40

무한반복을 통해 3입력값과 같아지는 시점에 결과물을 출력한다.

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

#include <iostream>
using namespace std;

int main()
{
    int e, s, m;
    cin >> e >> s >> m;
    int i = 0;
    int a = 0, b = 0, c = 0;
    while(true)
    {
        if(a == 16)
            a = 1;
        if(b == 29)
            b = 1;
        if(c == 20)
            c = 1;
        if(e == a && s == b && m == c)
        {
            break;
        }
        a++; b++; c++;
        i++;
    }
    cout << i << endl;
}
profile
☀️ Infra_Architecture 🔁 🌔 Game_Dev

0개의 댓글