#include<stdio.h>
int main()
{
int h1, m1, s1;
int h2, m2, s2;
int a, b, c;
scanf("%d:%d:%d", &h1, &m1, &s1);
scanf("%d:%d:%d", &h2, &m2, &s2);
if (h1 * 3600 + m1 * 60 + s1 < h2 * 3600 + m2 * 60 + s2)
{
a = h2 - h1, b = m2 - m1, c = s2 - s1;
if (c < 0)
{
c = 60 + c;
b--;
}
if (b < 0)
{
b = b + 60;
a--;
}
}
else
{
a = h1 - h2, b = m1 - m2, c = s1 - s2;
if (c < 0)
{
c = 60 + c;
b--;
}
if (b < 0)
{
b = b + 60;
a--;
}
}
printf("%d:%02d:%02d", a, b, c);
}
从键盘输入两个时间点(24小时制),输出两个时间点之间的时间间隔,时间间隔用“小时:分钟:秒”表示。
猜你喜欢
转载自blog.csdn.net/weixin_43343116/article/details/86261855
今日推荐
周排行