10黑马币
倒计时的算法:输入一个秒数,要求转换为
[p=256, null, left]XX[p=256, null, left]小时[p=256, null, left]XX[p=256, null, left]分[p=256, null, left]XX[p=256, null, left]秒的格式输出出来[p=256, null, left]; |
最佳答案
查看完整内容
import java.util.Scanner;
public class TestTime {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("请输出秒数");
int second =s.nextInt();
int hour=second/3600;
int minite=second%3600/60;
int sec=second%60;
System.out.println("转换后为:"+hour+"小时:"+minite+"分钟:"+sec+"秒");
}
}
|