给定秒数 seconds ,把秒转化成小时、分钟和秒。
数据范围:
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num = scan.nextInt(); System.out.print(num/3600 + " " + (num%3600)/60 + " " + num%60); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int a = in.nextInt(); int h =a/3600; int m = (a - h*3600)/60; int s =a - h*3600 - m*60; System.out.println(h+" "+m+" "+s); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { //键盘录入 Scanner in = new Scanner(System.in); while (in.hasNextInt()) { long seconds = in.nextInt(); //转换成小时、分钟、秒 /*1 hour=3600s 1 min=60s 类似于求个位、十位*/ long hours=seconds/3600; long mins=(seconds%3600)/60; seconds=seconds%60; //打印结果 System.out.println(hours+" "+mins+" "+seconds); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int inputSecond = scanner.nextInt(); int hour = inputSecond / (60 * 60); int minute = (inputSecond % (60 * 60)) / 60; int toChangeSecond = inputSecond % 60; System.out.println(hour + " " + minute + " " + toChangeSecond); } }
import java.util.*; public class Main { public static String gethour(int seconds){ int hour=seconds/3600; int min=seconds%3600/60; int sec=seconds%60; String result=hour+" "+min+" "+sec; return result; } public static void main(String [] args) { Scanner sc=new Scanner(System.in); int X=sc.nextInt(); System.out.print(gethour(X)); } }
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); int seconds = in.nextInt(); int hour = 0; int min = 0; int second = 0; if (seconds>=3600){ hour = seconds/3600; seconds = seconds%3600; } if (seconds>=60){ min = seconds/60; seconds = seconds%60; } if (seconds<60){ second = seconds; } System.out.println(hour+" "+min+" "+second); } }