using System; namespace timeDemo{ class timeDemo{ static void Main(string[] args){ int insecond; int hours,minutes,seconds; Console.WriteLine("Please input the seconds!");//input your seconds insecond=int.Parse(Console.ReadLine()); if(insecond>=3600) //over one hour { hours=insecond/3600; minutes=(insecond%3600)/60; seconds=(insecond%3600)%60; } else if(insecond>=60) //less than one hour but over one minute { hours=0; minutes=insecond/60; seconds=(insecond%60)%60; } else //less than one minute { hours=0; minutes=0; seconds=insecond; } Console.WriteLine("the result is: {0} hours {1} minutes {2} seconds!",hours,minutes,seconds); Console.Read(); } } }
输入秒数输出相应时分秒
最新推荐文章于 2023-12-23 13:20:59 发布