Created
August 24, 2012 23:02
-
-
Save gennad/3456887 to your computer and use it in GitHub Desktop.
144-2-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <sstream> | |
#include <assert.h> | |
class Time { | |
public: | |
std::string whatTime(int seconds); | |
}; | |
std::string Time::whatTime(int seconds) { | |
std::stringstream out; | |
std::string hours_s, mins_s, secs_s; | |
int hours, mins, secs; | |
hours = seconds / (60 * 60); | |
out << hours; | |
hours_s = out.str(); | |
out.str(""); | |
seconds = seconds - (hours * 60 * 60); | |
mins = seconds / 60; | |
seconds = seconds - (mins * 60); | |
secs = seconds; | |
out << secs; | |
secs_s = out.str(); | |
out.str(""); | |
out << mins; | |
mins_s = out.str(); | |
out.str(""); | |
out << hours_s << ":" << mins_s << ":" << secs_s; | |
return out.str(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment