zoukankan      html  css  js  c++  java
  • HDU4510 模拟

    腾讯马拉松

    水~~

    注意是12小时一周期!!!!!!!!!!!!!!!!!!!!!!!

    View Code
     1 #include<stdio.h>
     2 #include<string.h>
     3 struct node{
     4     int h,m,s,all;
     5 };
     6 node now,pre,tmp;
     7 int main(){
     8     int n;
     9     scanf("%d",&n);
    10     while( n-- ){
    11         scanf("%d:%d:%d",&now.h,&now.m,&now.s);
    12         now.all = now.h*3600+now.m*60+now.s;
    13         scanf("%d:%d:%d",&tmp.h,&tmp.m,&tmp.s);
    14         while( tmp.h>=12 ){
    15             tmp.h -= 12;
    16         }
    17         tmp.all = tmp.h*3600+tmp.m*60+tmp.s;
    18         int tot;
    19         tot = now.all - tmp.all;
    20         if( tot >=0 ){ 
    21             pre.h = tot/3600,tot = tot - pre.h*3600;
    22             pre.m = tot/60, tot = tot - pre.m*60;
    23             pre.s = tot;
    24             printf("%02d:%02d:%02d\n",pre.h,pre.m,pre.s);
    25         }
    26         else{
    27             tot=-tot;
    28             pre.h = tot/3600,tot = tot - pre.h*3600;
    29             pre.m = tot/60, tot = tot - pre.m*60;
    30             pre.s = tot;
    31             now.h=12,now.m=0,now.s=0;
    32             if( now.s<pre.s ){
    33                 now.m = 59;
    34                 now.h = 11;
    35                 now.s = 60-pre.s;
    36             }
    37             else {}
    38             if( now.m<pre.m ){
    39                 now.m += 60;
    40                 now.m -= pre.m;
    41                 now.h --;
    42             }
    43             else{
    44                 now.m-=pre.m;
    45             }
    46             now.h-=pre.h;
    47 
    48             printf("%02d:%02d:%02d\n",now.h,now.m,now.s);
    49         }
    50     }
    51     return 0;
    52 }
    keep moving...
  • 相关阅读:
    vue中用解构赋值的方法引入组件
    es6--promise
    VUE设置浏览器icon图标
    vue项目之购物车
    vue之组件通信
    hbulider 快捷键
    Redis详解(3)--5大数据类型
    Redis详解(1)--redis简介与安装
    Redis详解(2)--redis配置文件介绍
    Python面试综合--web相关
  • 原文地址:https://www.cnblogs.com/xxx0624/p/2976448.html
Copyright © 2011-2022 走看看