HDU 4510

省一等,保研。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int H,M,S,h,m,s;

int main(){
    int T;
    bool flag1,flag2;
    scanf("%d",&T);
    while(T--){
        flag1=flag2=false;
        scanf("%d:%d:%d %d:%d:%d",&H,&M,&S,&h,&m,&s);
        if(S<s){
            flag1=true;
            S+=60;
        }
        S-=s;
        if(flag1)
        M--;
        if(M<m){
            flag2=true;
            M+=60;
        }
        M-=m;
        if(flag2)
        H--;
        H-=h;
        H%=12;
        H=(H+12)%12;
        printf("%02d:%02d:%02d
",H,M,S);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/jie-dcai/p/4343016.html