#include<iostream> #include<cstdio> #include<math.h> using namespace std; int main() { int h1, m1, s1; int h2, m2, s2; int t1, t2; scanf("%d:%d:%d", &h1, &m1, &s1); scanf("%d:%d:%d", &h2, &m2, &s2); t1 = h1 * 3600 + m1 * 60 + s1; t2 = h2 * 3600 + m2 * 60 + s2; t1 = abs(t1 - t2); h1 = t1 / 3600; t1 %= 3600; m1 = t1 / 60; s1 = t1 % 60; printf("%d:%02d:%02d", h1, m1, s1); return 0; } |
Double click to view unformatted code.