Baekjoon/C++

[백준/BOJ]2525번 오븐 시계

developerwkddbs 2024. 11. 5. 10:30
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    int h,m,t; //시간,분,요리시간 입력변수
    cin >> h >> m >> t;
    if(h<0&&h>23||m<0&&m>59||t<0&&t>1000)
        exit(0);
    m=m+t;
    if(m>=60)
    {
        h=h+(m/60);
        m=m%60;
    }
    if(h>=24)
    {
        h=h%24;
    }
    cout<<h<<' '<<m<<'\n';
}

 

질문은 happyoon913@gmail.com으로 보내주세요.