#include <stdio.h> #include <string.h> void main() { int h_1, m_1, s_1; int h_2, m_2, s_2; int h, m, s; int t1, t2; scanf("%d:%d:%d", &h_1, &m_1, &s_1); scanf("%d:%d:%d", &h_2, &m_2, &s_2); t1 = h_1 * 3600 + m_1 * 60 + s_1; t2 = h_2 * 3600 + m_2 * 60 + s_2; if (t1 > t2) { int t = t1; t1 = t2; t2 = t; } h = (t2 - t1) / 3600; m = (t2 - t1 - h * 3600) / 60; s = t2 - t1 - h * 3600 - m * 60; printf("%d:", h); if (m < 10) { printf("0%d:", m); } else { printf("%d:", m); } if (s < 10) { printf("0%d", s); } else { printf("%d", s); } } |
Double click to view unformatted code.