1001小Q系列故事——为什么时光不能倒流

写了个特别挫的:
 #include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main()
{

    int llc=0;
    cin>>llc;
for(int j=0;j<llc;j++)
{

    string str;
    int H,M,S;
    int h,m,s;
    int a,b,c;
    cin>>str;
    H=(str[0]-48)*10+(str[1]-48);
    M=(str[3]-48)*10+(str[4]-48);
    S=(str[6]-48)*10+(str[7]-48);
    cin>>str;
    h=(str[0]-48)*10+(str[1]-48);
    m=(str[3]-48)*10+(str[4]-48);
    s=(str[6]-48)*10+(str[7]-48);

    while(h>=12)
    {
        h=h-12;
    }

    if(S-s>=0)
    {
        c=S-s;
    }
    else
    {
       if(M-1>=0)
       {
        S=S+60;
        M=M-1;
        c=S-s;
       }
       else
       {
        M=M+60;
        H=H-1;

        S=S+60;
        M=M-1;
        c=S-s;
       }
    }

    if(M-m>=0)
    {
        b=M-m;
    }
    else
    {
        M=M+60;
        H=H-1;
        b=M-m;
    }

    H=H-h;
    if(H>=0)
    {
        a=H;
    }
    else
    {
        H=H+12;
        a=H;
    }

    ios::sync_with_stdio();
    printf("%02d:%02d:%02d\n",a,b,c);

    //cout<<h<<m<<s;

}
    return 0;
}
原文地址:https://www.cnblogs.com/CKboss/p/3351124.html