Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- void wait ( int seconds )
- {
- clock_t endwait;
- endwait = clock () + seconds * CLOCKS_PER_SEC ;
- while (clock() < endwait) {}
- }
- class Timer
- {
- private:
- time_t value;
- public:
- Timer() { value = time(NULL);};
- void add(int h, int m, int s);
- void show();
- };
- void Timer::add(int h, int m, int s)
- {
- value -= s + m * 60 + h * 3600;
- }
- void Timer::show()
- {
- std::cout << difftime(time(NULL), value);
- }
- int main()
- {
- Timer T;
- T.add(0, 0, 30);
- wait(5);
- T.show();
- return 0;
- }
Add Comment
Please, Sign In to add comment