很水,将秒转换为时分秒的格式;
int h = seconds/3600; int m = (seconds%3600)/60; int s = seconds%60;
class Time
{
public:
string whatTime(int seconds)
{
char ch[12];
int h = seconds/3600;
int m = (seconds%3600)/60;
int s = seconds%60;
sprintf(ch,"%d:%d:%d", h, m, s);
string str(ch);
return str;
}
}