Blue Bridge Cup VIP questions of basic training time conversion - JAVA

Blue Bridge Cup VIP questions of basic training time conversion - JAVA

Title Description

Given a time in units of seconds t, the time to represent the requirements for the format of "<H>: <S>: <M>". <H> represents time, <M> represents minutes, and <S> expressed in seconds, which are integers with no leading "0." For example, if t = 0, the output should be "0: 0: 0"; if t = 3661, and outputs "1: 1: 1."

Input
Input only one line, is an integer t (0 <= t <= 86399).

Output
Output only one line, it is "<H>: <M> : <S>" indicated by the time format, without quotes.

Sample input
5436

Sample output
1:30:36


import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        //直接硬算就行了...
        int h=t/3600;
        int m=t%3600/60;
        int s=t%60;
        System.out.println(h+":"+m+":"+s);       
	}

}

Published 475 original articles · won praise 682 · views 520 000 +

Guess you like

Origin blog.csdn.net/Czhenya/article/details/104646669