Console.Write("Type in the number of seconds: ");
int total_seconds = Convert.ToInt32(Console.ReadLine());
int hours = total_seconds / 3600;
total_seconds = total_seconds % (hours * 3600);
int minutes = total_seconds / 60;
total_seconds = total_seconds % (minutes * 60);
int seconds = total_seconds;
Console.WriteLine("Number of hours: " + hours + " hours" + "\nNumber of minutes: " + minutes + " minutes" + "\nNumber of seconds: " + seconds + " seconds");
Console.ReadLine();
设法创建一个程序,将总秒数转换为相应的小时、分钟、秒。我遇到了一个问题,因为我不希望程序也能够在 3660 以下的总秒数内显示小时数、分钟数等,这似乎是不可能的。任何想法如何帮助解决这个问题?