學習筆記(24):C#急速入門-練習題5實戰

立即學習:https://edu.csdn.net/course/play/20589/257732?utm_source=blogtoedu

_______________________________________________________________________________________________________

人生碌碌,競短論長,卻不道榮枯有數,得失難忘。

_______________________________________________________________________________________________________

 

//    練習5:編程實現用戶輸入多少秒,然後程序轉化爲幾天幾小時幾分鐘幾秒?
            Console.WriteLine("請輸入多少秒:");
            string sec = Console.ReadLine();
            int _sec = Convert.ToInt32(sec);
            int h=_sec%(3600*24)/3600;
            Console.WriteLine("{0}秒爲第{1}天{2}小時{3}分{4}秒", sec, _sec / (3600 * 24), h, _sec % (3600 * 24) % 3600 / 60, _sec % (3600 * 24) % 3600 % 60);










            Console.ReadKey();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章