給定一個以秒爲單位的時間t,要求用 “<H>:<M>:<S>”的格式來表示這個時間。<H>表示時間,<M>表示分鐘, 而<S>表示秒,它們都是整數且沒有前導的“0”。例如,若t=0,則應輸出是“0:0:0”;若t=3661,則輸出“1:1:1”。
輸入格式
輸入只有一行,是一個整數t(0<=t<=86399)。
輸出格式
輸出只有一行,是以“<H>:<M>:<S>”的格式所表示的時間,不包括引號。
樣例輸入
0
樣例輸出
0:0:0
樣例輸入
5436
樣例輸出
1:30:36
這裏其實最主要考察的還是字符串轉化,建議用stringstream字符串流來操作。
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
using namespace std;
int main()
{
int time;
cin >> time;
int H, M, S;
H = M = S = 0;
H = time/3600;
M = time%3600/60;
S = time%60;
string out;
stringstream ss;
ss << H << ':' << M << ':' << S;
cout << ss.str();
return 0;
}