![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Professional Programmer
|
Simple clock
Got bored and made a very simple clock, could be of use to someone in some way.
#include <time.h>
#include <iostream>
using namespace std;
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLK_TCK ;
while (clock() < endwait) {}
}
int main() {
int monkey = 2;
int s = 0, ms = 0, hs = 0;
do{
s += 1;
if (s == 60){
s = 0;
ms += 1;
}
if (ms == 60){
ms = 0;
hs += 1;
}
wait(1.6);
system("CLS");
cout << hs << ":" << ms << ":" << s;
}while(monkey == 2);
return 0;
}
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
You should use the sleep function instead of a loop, because sleep uses nearly no processor time.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|