解题思路:
import java.util.Scanner; public class C1183 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); int ah = 0, am = 0, as = 0, bh = 0, bm = 0, bs = 0, h = 0, m = 0, s = 0, add = 0; while(n-- > 0){ ah = sc.nextInt(); am = sc.nextInt(); as = sc.nextInt(); bh = sc.nextInt(); bm = sc.nextInt(); bs = sc.nextInt(); //秒 s = as + bs; if(s >= 60){ add = s / 60; s = s % 60; }else{ add = 0; } //分 m = am + bm + add; if(m >= 60){ add = m / 60; m = m % 60; }else{ add = 0; } //时 h = ah + bh + add; System.out.printf("%d %d %d\n", h, m, s); } } sc.close(); } }
注意事项:
参考代码:
0.0分
0 人评分
简单的a+b (C语言代码)浏览:601 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:632 |
【魔板】 (C++代码)(时间超限,希望会的帮我改正一下)浏览:804 |
字符逆序 (C语言代码)浏览:645 |
1048题解(读入回车问题)浏览:628 |
第三届阿里中间件性能挑战赛-总决赛亚军比赛攻略浏览:1170 |
1052题解(链表操作)浏览:782 |
1197求助浏览:667 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:555 |
1074题 初学者,求帮忙看下,不知道哪错了浏览:297 |