請寫一程式,讓使用者可以輸入一個秒數數值,將該秒數轉成以日、時、分、秒來表示
import java.lang.*; public class caltime { public static void main(String[] args) throws Exception{ int day,hr,min,sec; //assume int inSec = 36758; // day day = inSec/(24*3600); inSec %= (24*3600); hr = inSec/(3600); inSec %= 3600; min = inSec/60; inSec %= 60; System.out.print(day+" day "+hr+" hour "+min+" minutes " +inSec+" Seconds "); } }
全站熱搜
留言列表