1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include<iostream>
#include<windows.h>
void gotoxy(int column, int line)
{
COORD coord;
coord.X = column;
coord.Y = line;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void display()
{
gotoxy(33, 8);
std::cout << "hr";
gotoxy(36, 8);
std::cout << "min";
gotoxy(40, 8);
std::cout << "sec";
}
int main()
{
int hours, secs, mins;
display();
for (int a = 30; a <= 45; a++)
{
gotoxy(a, 6);
std::cout << char(220);
}
for (int a = 45; a >= 30; a--)
{
gotoxy(a, 12);
std::cout << char(220);
}
for (int a = 13; a >= 5; a--)
{
gotoxy(31, a);
std::cout << char(219);
}
for (int a = 5; a <= 13; a++)
{
gotoxy(44, a);
std::cout << char(219);
}
for (hours = 1; hours <= 12; hours++)
{
gotoxy(34, 10);
if (hours < 10)
{
std::cout << " ";
}
std::cout << hours << ":";
for (mins = 0; mins < 60; mins++) // notice the change
{
gotoxy(37, 10);
if (mins < 10)
{
std::cout << "0";
}
std::cout << mins <<":";
for (secs = 0; secs < 60; secs++) // notice the change
{
gotoxy(40, 10);
if (secs < 10)
{
std::cout << "0";
}
std::cout << secs;
Sleep(750); // the Sleep() function is not a good time keeper
}
}
}
}
|