版权声明:本文为博主原创文章,采用“署名-非商业性使用-禁止演绎 2.5 中国大陆”授权。欢迎转载,但请注明作者姓名和文章出处。 https://blog.csdn.net/njit_77/article/details/79747354
Challenge
Using the C# language, have the function
TimeConvert(num) take the
num parameter being passed and return the number of
hours and
minutes the parameter converts to (
ie. if
num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon.
Sample Test Cases
Input:126
Output:"2:6"
Input:45
Output:"0:45"
Time Convert算法把输入的int数值转换成时间(小时:分钟)
public static string TimeConvert(int num)
{
int hours = 0;
int minutes = 0;
hours = num / 60;
minutes = num % 60;
return string.Format("{0}:{1}", hours, minutes);
}