Cf387A
来源:互联网 发布:淘宝女士连衣裙 编辑:程序博客网 时间:2024/05/17 07:54
<span style="color:#6600cc;">/*C - George and SleepTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64uSubmit Status Practice CodeForces 387ADescriptionGeorge 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).InputThe 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.OutputIn 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 InputInput05:5005:44Output00:06Input00:0001:00Output23:00Input00:0100:00Output00:01HintIn the first sample George went to bed at "00:06". Note that you should print the time only in the format "00:06". That's why answers "0:06", "00:6" and others will be considered incorrect.In the second sample, George went to bed yesterday.In the third sample, George didn't do to bed at all.By Grant Yuan2014.7.11*/#include<iostream>#include<stdio.h>#include<stdlib.h>#include<string.h>using namespace std;int h1,m1;int h2,m2;int main(){ scanf("%d:%d",&h1,&m1); scanf("%d:%d",&h2,&m2); int h3,m3; if(m1<m2) {h1=(h1+24-1)%24; m3=m1+60-m2; } else m3=m1-m2; if(h1<h2) h3=(h1+24-h2)%24; else h3=h1-h2; //cout<<h3<<":"<<m3<<endl; if(h3<10) cout<<"0"<<h3; else cout<<h3; if(m3<10) cout<<":"<<"0"<<m3<<endl; else cout<<":"<<m3<<endl; return 0;}</span>
0 0