/*** ! 在程序运行过程中不要切换窗口,否则,会出错 . ***/
#include<graphics.h>
#include<math.h>
#include<time.h>
#define STEP 6.283183/60
#define PI 3.141592
#define X 307
#define Y 150 /*** 中心坐标 ***/
#define R 100
#define R_OUT (R+4) /*** 内外半径 ***/
#define R_S (R-20)
#define R_M (R-35)
#define R_H (R-50) /*** 各指针半径 ***/
#define MIN 60 /*** 设定延时 (分钟) ***/
#define C_I 9
int HH=0,MM=0;
main()
{
int gd=DETECT,gm,second,record_s,minite,record_m,hour,i,pc=60;
time_t t; float temp; char ch='#';
int int_M=MIN; pc=(MIN-int_M)*60;
initgraph (&gd,&gm,""); setbkcolor (0);
/*** 外观设计 ***/
circle (X,Y,R); setfillstyle (1,2); floodfill (X,Y,15);
circle (X,Y,R_OUT); setfillstyle (1,8); floodfill (X+R_OUT-1,Y,15);
rectangle (X-2,Y-R+8-4,X+2,Y-R+8+4);
rectangle (X-2,Y+R-8-4,X+2,Y+R-8+4);
rectangle (X-R+8-4,Y-2,X-R+8+4,Y+2);
rectangle (X+R-8-4,Y-2,X+R-8+4,Y+2);
for (i=1;i<=60;i++)
if (i!=15&&i!=30&&i!=45&&i!=60)
if (i%5!=0) circle (X+(R-10)*cos(i*STEP),Y+(R-10)*sin(i*STEP),1);
else circle (X+(R-10)*cos(i*STEP),Y+(R-10)*sin(i*STEP),2);
rectangle (X+R_OUT,Y-6,X+R_OUT+6,Y+6);
setfillstyle (1,8); floodfill (X+R_OUT+3,Y,15);
temp=R_OUT*0.866;
line (X-R_OUT/2-5,Y-temp+2,X-R_OUT/2,Y-temp-30);
line (X-R_OUT/2+5,Y-temp-2,X-R_OUT/2+5,Y-temp-30);
line (X+R_OUT/2-5,Y-temp-2,X+R_OUT/2-5,Y-temp-30);
line (X+R_OUT/2+5,Y-temp+2,X+R_OUT/2,Y-temp-30);
line (X-R_OUT/2,Y-temp-30,X-R_OUT/2+5,Y-temp-30);
line (X+R_OUT/2-5,Y-temp-30,X+R_OUT/2,Y-temp-30);
line (X-R_OUT/2+5,Y-temp-25,X+R_OUT/2-5,Y-temp-25);
line (X-R_OUT/2+5,Y-temp-22,X+R_OUT/2-5,Y-temp-22);
floodfill (X-R_OUT/2-2,Y-temp,15);
floodfill (X+R_OUT/2+2,Y-temp,15);
floodfill (X,Y-R_OUT-10,15);
line (X-R_OUT/2-5,Y+temp-2,X-R_OUT/2,Y+temp+30);
line (X-R_OUT/2+5,Y+temp+2,X-R_OUT/2+5,Y+temp+30);
line (X+R_OUT/2-5,Y+temp+2,X+R_OUT/2-5,Y+temp+30);
line (X+R_OUT/2+5,Y+temp-2,X+R_OUT/2,Y+temp+30);
line (X-R_OUT/2,Y+temp+30,X-R_OUT/2+5,Y+temp+30);
line (X+R_OUT/2-5,Y+temp+30,X+R_OUT/2,Y+temp+30);
line (X-R_OUT/2+5,Y+temp+25,X+R_OUT/2-5,Y+temp+25);
line (X-R_OUT/2+5,Y+temp+22,X+R_OUT/2-5,Y+temp+22);
floodfill (X-R_OUT/2-2,Y+temp,15);
floodfill (X+R_OUT/2+2,Y+temp,15);
floodfill (X,Y+R_OUT+10,15);
for (i=1;i<=MIN*60+1;i++) /*** 该循环严格一秒一次 ( 捕捉系统时间 ) ***/
{
setcolor (15);
circle (X,Y,5); circle (X,Y,2); setfillstyle (1,0); floodfill (X,Y,15);
settextstyle (2,0,0); setcolor (8); outtextxy (X-13,Y-52,"FIYTA");
outtextxy (X-30,Y+35,"MADE IN 127"); setcolor (2);
time (&t); /*** 获取系统时间 ***/
hour=(ctime(&t)[11]-'0')*10+(ctime(&t)[12]-'0');
minite=(ctime(&t)[14]-'0')*10+(ctime(&t)[15]-'0');
second=(ctime(&t)[17]-'0')*10+(ctime(&t)[18]-'0');
if (ch==C_I) { HH=HH-hour; MM=MM-minite; }
hour=(hour+HH)%24; minite=(minite+MM)%60;
window (22,22,80,22); printf (" The current time is ");
if (hour<10) printf ("0"); printf ("%d : ",hour);
if (minite<10) printf ("0"); printf ("%d : ",minite);
if (second<10) printf ("0"); printf ("%d",second);
window (35,20,80,20);
printf (" "); if (int_M<10) printf ("0"); printf ("%d : ",int_M);
if (pc<10) printf ("0"); printf ("%d ",pc);
record_m=minite;
hour=10*hour+minite/6-30;
minite=2*minite+second/30-30;
second-=15; record_s=second;
setcolor (0); /*** 写指针 ***/
line (X+7*cos(PI+hour*STEP/2),Y+7*sin(PI+hour*STEP/2),X+R_H*cos(hour*STEP/2),Y+R_H*sin(hour*STEP/2));
setcolor (1);
line (X+13*cos(PI+minite*STEP/2),Y+13*sin(PI+minite*STEP/2),X+R_M*cos(minite*STEP/2),Y+R_M*sin(minite*STEP/2));
setcolor (4);
line (X+20*cos(PI+second*STEP),Y+20*sin(PI+second*STEP),X+R_S*cos(second*STEP),Y+R_S*sin(second*STEP)); record_s=second;
ch='#';
while (second==record_s) /*** 此循环用来 " 监视 " 系统秒针的变化 ***/
{
time (&t); second=(ctime(&t)[17]-'0')*10+(ctime(&t)[18]-'0')-15;
if (bioskey(1)&&(ch=getch())==C_I||ch==27)
{
if (ch==27) { closegraph (); exit (0); }
window (22,22,80,22); printf (" PLS enter the time : ");
window (48,22,80,22);
while (!bioskey(1))
{ printf ("00:00 \b\b\b\b\b\b\b\b"); delay (25000); printf (" \b\b\b\b\b\b\b\b"); delay (25000); }
scanf ("%d:%d:%d",&HH,&MM);
if (HH<=23&&HH>=0&&MM>=0&&MM<=59) break; else { ch='#'; HH=0; MM=0; }
}
}
setcolor (2); /*** 覆盖指针 ( 由秒控制 ) ***/
if ((record_m*60+60+second+15)%360==0||ch==C_I)
line (X+7*cos(PI+hour*STEP/2),Y+7*sin(PI+hour*STEP/2),X+R_H*cos(hour*STEP/2),Y+R_H*sin(hour*STEP/2));
if ((second+15)%30==0||ch==C_I)
line (X+13*cos(PI+minite*STEP/2),Y+13*sin(PI+minite*STEP/2),X+R_M*cos(minite*STEP/2),Y+R_M*sin(minite*STEP/2));
if (i!=60*MIN+1||ch==C_I)
line (X+20*cos(PI+record_s*STEP),Y+20*sin(PI+record_s*STEP),X+R_S*cos(record_s*STEP),Y+R_S*sin(record_s*STEP));
if (pc==0&&int_M!=0) pc=60; pc--; if (pc==59) int_M--;
}
window (20,22,80,22);
printf (" The watch time out! Press any key ... "); getch ();
closegraph ();
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |