fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int h1, m1, s1, h2, m2, s2;
  6. int sum1, sum2, sec, time1, time2;
  7. int h3, m3, s3;
  8. cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
  9. sum1 = h1 + m1 * 24 + s1 * 24 * 60;
  10. sum2 = h2 + m2 * 24 + s2 * 24 * 60;
  11. sec = (sum2 - sum1 + 86400) % 86400;
  12. time1 = 3600 * h1 + 60 * m1 + s1;
  13. time2 = (time1 + sec) % 86400;
  14. s3 = time2 % 60;
  15. m3 = ((time2 - s3) / 60) % 60;
  16. h3 = (time2 - m3 * 60 - s3) / 3600;
  17. cout << h3 << " " << m3 << " " << s3;
  18. return 0;
  19. }
Success #stdin #stdout 0s 4300KB
stdin
16 0 17
16 0 18
stdout
16 24 17