importjava.io.*; importjava.util.*; public class Time { public static void main(String[] args) throws IOException { Scanner time = newScanner(System.in); int t,second,mm,hour,day; t = time.nextInt(); if(t >0){ if(t >=3600*24) //判断天数 { day = t/(3600*24); t= t- day * (3600*24); System.out.print(day+"天"); } if((3600*24)>t && t>=3600) { hour = t/3600; t = t -hour*3600; System.out.print(hour+"小时"); } if(3600>t && t>=60) { mm = t/60; t = t -mm*60; System.out.print(mm+"分钟"); } if(60>t && t>0) //判断秒 { second = t; System.out.print(second+"秒"); } }else{ System.out.print("输入的时间不对"); } } }
|