Problem Description
从键盘输入两个时间点(24小时制),输出两个时间点之间的时间间隔,时间间隔用“小时:分钟:秒”表示。
如:3点5分25秒应表示为–03:05:25.假设两个时间在同一天内,时间先后顺序与输入无关。
Input
输入包括两行。
第一行为时间点1。
第二行为时间点2。
Output
以“小时:分钟:秒”的格式输出时间间隔。
格式参看输入输出。
Sample Input
12:01:12
13:09:43
Sample Output
01:08:31
Hint
Source
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a1,b1,c1,a2,b2,c2,s1,s2,a3,b3,c3,s;
scanf("%d:%d:%d",&a1,&b1,&c1);
scanf("%d:%d:%d",&a2,&b2,&c2);
s1=a1*3600+b1*60+c1;
s2=a2*3600+b2*60+c2;
s=s1-s2;
if(s<0)s=-s;
a3=s/3600;
b3=(s-a3*3600)/60;
c3=(s-a3*3600)%60;
printf("%02d:%02d:%02d\n",a3,b3,c3);
return 0;
}