cf 227 除夕夜

A. George and Sleep
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t.

Help George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second test sample).

Input

The first line contains current time s as a string in the format "hh:mm". The second line contains time t in the format "hh:mm" — the duration of George's sleep. It is guaranteed that the input contains the correct time in the 24-hour format, that is, 00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59.

Output

In the single line print time p — the time George went to bed in the format similar to the format of the time in the input.

Sample test(s)
Input
05:50
05:44
Output
00:06
Input
00:00
01:00
Output
23:00
Input
00:01
00:00
Output
00:01
 
   
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int h1,h2,m1,m2;
    int c1=0,c2=0;
    scanf("%d:%d",&h1,&m1);
    scanf("%d:%d",&h2,&m2);
    if(m1>=m2)
    {
        c2=m1-m2;
    }
    else if(m1<m2)
    {
        h1=h1-1;
        c2=60-m2+m1;
    }
    if(h1>=h2)
    {
        c1=h1-h2;
    }
    else if(h1<h2)
    {

        c1=24-h2+h1;
    }
    if(c1<10)
    {
        printf("0%d",c1);
        printf(":");
        if(c2<10)
        {
            printf("0%d\n",c2);
        }
        else
        {
            printf("%d\n",c2);
        }
    }
    else
    {
        printf("%d",c1);
        printf(":");
        if(c2<10)
        {
            printf("0%d\n",c2);
        }
        else
        {
            printf("%d\n",c2);
        }
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值