#include<bios.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
int arrow_draw(int x, int y, int val, char type)
{
int xa,ya,len,temp;
double angle;
switch(type)
{
case 's':
{
len=80;
angle = (-90+val*6) * M_PI/180;
temp = (int)floor(len*cos(angle));
xa=x+temp;
temp = (int)floor(len*sin(angle));
ya=y+temp;
break;
}
case 'm':
{
len=60;
angle = (-90+val*6) * M_PI/180;
temp = (int)floor(len*cos(angle));
xa=x+temp;
temp = (int)floor(len*sin(angle));
ya=y+temp;
break;
}
case 'h':
{
len=40;
angle = (540 + val*30 + 90) * M_PI/180;
temp = (int)floor(len*cos(angle));
xa=x+temp;
temp = (int)floor(len*sin(angle));
ya=y+temp;
break;
}
}
line(x,y,xa,ya);
return 0;
}
int main(void)
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "e:/subject/bc/bgi");
int midx,midy,rad=100;
midx = getmaxx()/2;
midy = getmaxy()/2;
circle(midx,midy,rad);
int cur_s,cur_m,cur_h,pr_s,pr_m,pr_h;
struct time t;
while(bioskey(1)==0)
{
gettime(&t);
pr_s = cur_s;
pr_m = cur_m;
pr_h = cur_h;
cur_s = t.ti_sec;
cur_m = t.ti_min;
cur_h = t.ti_hour;
gotoxy(1,1);printf("%2d:%2d:%2d\n",cur_h,cur_m,cur_s);
if(pr_h!=cur_h)
{
setcolor(BLACK);
arrow_draw(midx,midy,pr_h,'h');
setcolor(WHITE);
arrow_draw(midx,midy,cur_h,'h');
}
if(pr_m!=cur_m)
{
setcolor(BLACK);
arrow_draw(midx,midy,pr_m,'m');
setcolor(WHITE);
arrow_draw(midx,midy,cur_m,'m');
}
if(pr_s!=cur_s)
{
setcolor(BLACK);
arrow_draw(midx,midy,pr_s,'s');
setcolor(WHITE);
arrow_draw(midx,midy,cur_s,'s');
}
sleep(1);
}
getch();
closegraph();
return 0;
}