Skip to content

Instantly share code, notes, and snippets.

@yuuki
Created May 23, 2012 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuuki/2775863 to your computer and use it in GitHub Desktop.
Save yuuki/2775863 to your computer and use it in GitHub Desktop.
SRM Div2-144 200score
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <string>
#include <iostream>
using namespace std;
class Time {
public:
string whatTime(int seconds) {
int h = seconds / 3600;
int m = seconds % 3600 / 60;
int s = seconds % 60;
char ss[9];
snprintf(ss, 9, "%d:%d:%d", h, m, s);
return ss;
}
};
int main() {
Time time;
cout << time.whatTime(0) << endl;
cout << time.whatTime(3661) << endl;
cout << time.whatTime(5436) << endl;
cout << time.whatTime(86399) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment