import java.util.Scanner; public class Main { static String time_judge(int time) {//这个方法判断sec,min,hour是否小于10 String s = ""; if(time/10 == 0) { s = "0"+time; } else { s = time+""; } return s; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(),a[] = new int[n]; for(int i=0;i<n;i++) { a[i] = scanner.nextInt(); } for(int i=0;i<n;i++) { String s1 = "",s2 = "",s3 = "";//用字符串解决简单一点 int sec = a[i]%60,min = a[i]/60%60,hour = a[i]/60/60; while(hour > 23) {//首先判断hour是否超过24 hour -= 24; } s1 = time_judge(sec);//sec --- 秒 s2 = time_judge(min);//min --- 分 s3 = time_judge(hour);//hour --- 时 System.out.println(s3+":"+s2+":"+s1); } } }
解题思路:
注意事项:
参考代码:
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:654 |
计算质因子 (C++代码)浏览:1827 |
WU-输出正反三角形 (C++代码)浏览:1100 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:544 |
母牛的故事 (C语言代码)浏览:1451 |
简单的a+b (C语言代码)浏览:1024 |
C语言程序设计教程(第三版)课后习题12.2 (C语言代码)浏览:839 |
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:765 |
简单的a+b (C语言代码)浏览:531 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:538 |