CodeFoeces-387A

题目

原题链接:A. George and Sleep

题意

给出当前的时间和经过时间,问初始时间。

代码

#include
using namespace std;
int main() {
    int sh,sm,th,tm;
    scanf("%d:%d",&sh,&sm);
    scanf("%d:%d",&th,&tm);
    sm-=tm;
    if(sm<0) {sm=60-abs(sm);sh--;}
    sh-=th;
    if(sh<0) sh=24-abs(sh);
    printf("%02d:%02d\n",sh,sm);
    return 0;
}

你可能感兴趣的:(CodeFoeces-387A)