@java blue bridge group B Problem Fundamentals cup (30) Question 14: Time Conversion
Keywords: modulo, numeric characters mixed output
Problem Description
Given a time in units of seconds t, requirements for ":: to represent the time" format. Indicating time minutes, and indicates 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 format
input only one line, is an integer t (0 <= t <= 86399).
Output format
output only one line, based on ":: Time" format indicated, without the quotes.
Input Sample
0
Sample Output
0: 0: 0
Sample Input
5436
Sample Output
1:30:36
Code:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int m=s.nextInt();
if(m>=0&&m<=86399){
int xiaoshi=m/3600;
int miao=m%60;
int fenzhong=m/60%60;
System.out.print(xiaoshi+":"+fenzhong+":"+miao);
}
}
}