zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    linq.js
    ES6入门
    Visual Studio Code之常备快捷键
    JavaScript——数组
    谈程序员的出路
    优秀博文
    多媒体封装格式详解---MP4
    音视频文件分析工具
    offsetof(s,m)解析
    GCC 提供的原子操作
  • 原文地址:https://www.cnblogs.com/CKboss/p/3351124.html
Copyright © 2011-2022 走看看