Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct Time
- {
- int hour;
- int minute;
- int second;
- };
- Time time;
- void setTime()
- {
- cout << "Set time: ";
- cin >> time.hour >> time.minute >> time.second;
- }
- void increase()
- {
- time.second++;
- time.minute += time.second / 60;
- time.second %= 60;
- time.hour += time.minute / 60;
- time.minute %= 60;
- time.hour %= 24;
- }
- void showTime()
- {
- cout << "Show time: ";
- if (time.hour < 10)
- cout << "0";
- cout << time.hour;
- cout << ":";
- if (time.minute < 10)
- cout << "0";
- cout << time.minute;
- cout << ":";
- if (time.second < 10)
- cout << "0";
- cout << time.second;
- }
- int main()
- {
- setTime();
- increase();
- increase();
- showTime();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement