输入程序,将输入的以秒为计时单位的时间长度拆分成时、分、秒计量 5
1个回答
展开全部
控制台做的.只用了一个结构变量. struct Timeclass
{
public int Hour;
public int Minute;
public int Second;
} class Program7
{ public static void Main(string[] args)
{
Console.Write("秒数:");
string a = Console.ReadLine();
int b = Int32.Parse(a);
Timeclass i;
i.Second = b% 60;
i.Minute = ((b - i.Second) / 60) % 60;
i.Hour = (b - i.Second) / 3600;
Console.WriteLine(string.Format("{0}小时{1}分{2}秒", i.Hour, i.Minute, i.Second)); }
}
{
public int Hour;
public int Minute;
public int Second;
} class Program7
{ public static void Main(string[] args)
{
Console.Write("秒数:");
string a = Console.ReadLine();
int b = Int32.Parse(a);
Timeclass i;
i.Second = b% 60;
i.Minute = ((b - i.Second) / 60) % 60;
i.Hour = (b - i.Second) / 3600;
Console.WriteLine(string.Format("{0}小时{1}分{2}秒", i.Hour, i.Minute, i.Second)); }
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询