#include <stdio.h> #include <iostream> #include <string.h> #include <string> #include <algorithm> #include <iomanip> #include<vector> #include<math.h> using namespace std; void swap(int *x, int *y) { int t; t = *x; *x = *y; *y = t; } int main() { int a, b, c; int d, e, f; scanf("%d:%d:%d", &a,&b,&c); scanf("%d:%d:%d", &d,&e,&f); if (a < d) { swap(a, d); swap(b, e); swap(c, f); } int g, h, i; if (c >= f) { i = c - f; } if (c < f) { b--; i = c + 60 - f; } if (b >= e) { h = b - e; } if (b < e) { a--; h = b + 60 - e; } g = a - d; cout << setw(2)<<setfill('0')<<g << ":" << setw(2) << setfill('0') << h << ":" << setw(2) << setfill('0') << i ; } |
Double click to view unformatted code.