#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <dos.h>
#include <stdio.h>
void Main ()
{
int gd=detect,gm;
int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec;
struct time t;
Char n[12][3]={"3", "2", "1", "12", "11", "10", "9", "8", "7", "6", "5", "4"};
Initgraph (&GD,&GM, "G:\TC\BGI");//Graphics drive path, replace according to your system.
Circle (x,y,210);
SetColor (4);
Settextstyle (4,0,5);
for (i=0;i<12;i++)
{
if (i!=3)
Outtextxy (x+ (r-14) *cos (m_pi/6*i) -10,y-r-14 (*sin) m_pi/6*i]);
Else
Outtextxy (x+ (r-14) *cos (m_pi/6*i) -20,y-r-14 (*sin) m_pi/6*i]);
}
GetTime (&t);
printf ("The current time is:%2d:%02d:%02d.%0 2d\n ", T.ti_hour, T.ti_min,
T.ti_sec, T.ti_hund);
while (!kbhit ())
{
SetColor (5);
Setfillstyle (1,5);
Circle (x,y,10);
FloodFill (x,y,5);
GetTime (&t);
if (t.ti_min!=m)
{
SetColor (0);
Line (x,y,x+ (r-60) *cos (thetamin* (m_pi/180)), Y (r-60) *sin (thetamin* (m_pi/180
)));
Circle (x+ (r-80) *cos (thetamin* (m_pi/180)), Y (r-80) *sin (thetamin* (m_pi/180))
, 10);
Line (x,y,x+ (r-110) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-110) *sin (m_pi/6*h
-((M/2) * (m_pi/180)));
Circle (x+ (r-130) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-130) *sin (m_pi/6*h-(
(M/2) * (m_pi/180)), 10);
}
if (t.ti_hour>12)
t.ti_hour=t.ti_hour-12;
if (t.ti_hour<4)
H=abs (t.ti_hour-3);
Else
H=15-t.ti_hour;
M=t.ti_min;
if (t.ti_min<=15)
Thetamin= (15-t.ti_min) *6;
Else
thetamin=450-t.ti_min*6;
if (t.ti_sec<=15)
Thetasec= (15-t.ti_sec) *6;
Else
thetasec=450-t.ti_sec*6;
SetColor (4);
Line (x,y,x+ (r-110) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-110) *sin (m_pi/6*h
-((M/2) * (m_pi/180)));
Circle (x+ (r-130) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-130) *sin (m_pi/6*h-(
(M/2) * (m_pi/180)), 10);
Line (x,y,x+ (r-60) *cos (thetamin* (m_pi/180)), Y (r-60) *sin (thetamin* (m_pi/180
)));
Circle (x+ (r-80) *cos (thetamin* (m_pi/180)), Y (r-80) *sin (thetamin* (m_pi/180))
, 10);
SetColor (15);
Line (x,y,x+ (r-70) *cos (thetasec* (m_pi/180)), Y (r-70) *sin (thetasec* (m_pi/180
)));
Delay (1000);
SetColor (0);
Line (x,y,x+ (r-70) *cos (thetasec* (m_pi/180)), Y (r-70) *sin (thetasec* (m_pi/180
)));
}
}
The program has been compiled in Turbo c++3.0.