//附上链接:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/1177.html
//这道题千万别用 if else 来做,麻烦死,而且说不定会 超时
//直接 转换成 秒 来运算行了
#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
int main()
{
int t, t1, t2, h1, h2, m1, m2,s1, s2;
char x;
cin >> h1 >> x >> m1 >> x >> s1;
cin >> h2 >> x >> m2 >> x >> s2;
t1 = h1 * 3600 + m1 * 60 + s1;
t2 = h2 * 3600 + m2 * 60 + s2;
if (t1 > t2)
{
t = t1-t2;
}
else
{
t = t2-t1;
}
h1 = t / 3600;
m1 = (t % 3600) / 60;
s1 = t % 3600 % 60;
printf("%02d:%02d:%02d\n", h1, m1, s1);
return 0;
}
C语言实验——时间间隔 1177
猜你喜欢
转载自blog.csdn.net/cjava__/article/details/80834641
今日推荐
周排行