fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int h1, m1, s1, h2, m2, s2;
  7. int sum1, sum2, sec, time1, time2;
  8. int h3, m3, s3;
  9. h1 = sc.nextInt();
  10. m1 = sc.nextInt();
  11. s1 = sc.nextInt();
  12. h2 = sc.nextInt();
  13. m2 = sc.nextInt();
  14. s2 = sc.nextInt();
  15. sum1 = h1 + m1 * 24 + s1 * 24 * 60;
  16. sum2 = h2 + m2 * 24 + s2 * 24 * 60;
  17. sec = (sum2 - sum1 + 86400) % 86400;
  18. time1 = 3600 * h1 + 60 * m1 + s1;
  19. time2 = (time1 + sec) % 86400;
  20. s3 = time2 % 60;
  21. m3 = ((time2 - s3) / 60) % 60;
  22. h3 = (time2 - m3 * 60 - s3) / 3600;
  23. System.out.print(h3 + " " + m3 + " " + s3);
  24. }
  25. }
Success #stdin #stdout 0.13s 2184192KB
stdin
1 13 18
22 51 32
stdout
7 4 51