来源(null)

这个程序很简单,你们自己研究一下就明白了。呵呵!

/****************************************************
Module:clock.c
Notices:Copyright (c) 2001 lijun
just a test of my programming ability
*****************************************************/
#include"math.h"
#include"dos.h"
#include"stdio.h"
#include"graphics.h"
main()
{
char s[30];
int gdriver,gmode;
int cosh,sinh,cosm,sinm,coss,sins;
struct time t;
char keydown=0;
int x=300,y=160,r=40;
clrscr();
gdriver=9; gmode=1;
initgraph(&gdriver,&gmode,"a:\\");/*需要说明的是,第三个参数a:\\是egavga.bgi这个文件的路径*/

/* install the graphic device.the third parameter is the path of the driver*/

setbkcolor(0);
setcolor(WHITE);
while(1)
{

circle(x,y,r); /*paint the circle*/

line(x,y+r-10,x,y+r-12);
line(x+r-4,y,x+r,y);
line(x-r,y,x-r+4,y);
line(x,y-r+10,x,y-r+10+2); /* draw the fout scales */

gettime(&t);
sprintf(s,"The current time is %2d:%02d:%02d\n",t.ti_hour,t.ti_min,t.ti_sec,t);
outtextxy(0,0,s); /* out put the current time */
outtextxy(0,10,"This clock is written by lijun"); /* show the auther */
coss=(int)((r-10)*cos(t.ti_sec*3.14f/30-3.14f/2)+x);
sins=(int)((r-10)*sin(t.ti_sec*3.14f/30-3.14f/2)+y);
cosm=(int)((r-19)*cos(t.ti_min*3.14f/30-3.14f/2)+x);
sinm=(int)((r-19)*sin(t.ti_min*3.14f/30-3.14f/2)+y);
cosh=(int)((r-28)*cos((t.ti_hour+(float)(t.ti_min)/60)*3.14f/6-3.14f/2)+x);
sinh=(int)((r-28)*sin((t.ti_hour+(float)(t.ti_min)/60)*3.14f/6-3.14f/2)+y);

/* calculate the position of the three points */
setcolor(14);
line(x,y,coss,sins);
setcolor(13);
line(x,y,cosm,sinm);
setcolor(10);
line(x,y,cosh,sinh);
setcolor(15);

/* draw the points */

sleep(1);
clrscr();
keydown=kbhit(); /* check whether key down */
if(keydown)
{
closegraph(); /* close graphic device */
exit(0);
}
}

}

Link: http://www.asm32.net/article_details.aspx?id=1048