Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Time
- {
- public:
- Time(int h, int m, int s) :
- hours(h), minutes(m), seconds(s)
- {}
- int to_hours() const
- {
- return hours + minutes / 60 + seconds / 3600;
- }
- int to_minutes() const
- {
- return hours * 60 + minutes + seconds / 60;
- }
- int to_seconds() const
- {
- return hours * 3600 + minutes * 60 + seconds;
- }
- private:
- int hours, minutes, seconds;
- };
- int main()
- {
- int hours, minutes, seconds;
- cin >> hours >> minutes >> seconds;
- Time t(hours, minutes, seconds);
- cout << t.to_hours() << endl << t.to_minutes() << endl << t.to_seconds() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement