/* HELLO.C -- Hello, world */
#include "stdio.h"
#include "conio.h"
#include "dos.h"
#include "math.h"
#include <graphics.h>
#define pi 3.1415926
main()
{
struct time curtime;
float th_hour,th_min,th_sec;
int graphdriver = DETECT,graphmode,maxx,maxy,end_x,end_y;
initgraph(&graphdriver,&graphmode,"c:/123");/*c:/123改了就可以用,把它改成你存放TC中BGI文件夹中的途径,
例如:你把TC存放在D盘,c:/tc2/BGI*/
maxx = getmaxx();
setcolor(10);
maxy = getmaxy();
while (1)
{
circle(maxx/2,maxy/2,150);
circle(maxx/2,maxy/2,2);
gettime(&curtime);
th_sec = curtime.ti_sec;
end_x = maxx/2 + sin(th_sec*2*pi/60)*130;
end_y = maxy/2 - cos(th_sec*2*pi/60)*130;
line(end_x,end_y,maxx/2,maxy/2);
th_min = curtime.ti_min;
end_x = maxx/2 + sin(th_min*2*pi/60 + th_sec*2*pi/60/60.0)*100;
end_y = maxy/2 - cos(th_min*2*pi/60 + th_sec*2*pi/60/60.0)*100;
line(end_x,end_y,maxx/2,maxy/2);
th_hour = curtime.ti_hour;
if (th_hour >= 12)
th_hour = th_hour - 12;
end_x = maxx/2 + sin(th_hour*2*pi/12 + (th_min*2*pi/60 + th_sec*2*pi/60/60.0)/12)*70;
end_y = maxy/2 - cos(th_hour*2*pi/12 + (th_min*2*pi/60 + th_sec*2*pi/60/60.0)/12)*70;
line(end_x,end_y,maxx/2,maxy/2);
sleep(1);
cleardevice();
}
}