|
#include<graphics.h> <br/> #include<conio.h> <br/> #include<math.h> <br/> #include<dos.h> <br/> #include<stdio.h> <br/> void main() <br/> { <br/> int gd=DETECT,gm; <br/> int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec; <br/> struct time t; <br/> char n[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"}; <br/> initgraph(&gd,&gm,"g:\\tc\\bgi");//图形驱动器路径,根据自己的系统更换。 <br/> circle(x,y,210); <br/> setcolor(4); <br/> settextstyle(4,0,5); <br/> for(i=0;i<12;i++) <br/> { <br/> if(i!=3) <br/> outtextxy(x+(r-14)*cos(M_PI/6*i)-10,y-(r-14)*sin(M_PI/6*i)-26,n); <br/> else <br/> outtextxy(x+(r-14)*cos(M_PI/6*i)-20,y-(r-14)*sin(M_PI/6*i)-26,n); <br/> } <br/> gettime(&t); <br/> printf("The current time is: %2d:%02d:%02d.%02d\n",t.ti_hour, t.ti_min, <br/> t.ti_sec, t.ti_hund); <br/> while(!kbhit()) <br/> { <br/> setcolor(5); <br/> setfillstyle(1,5); <br/> circle(x,y,10); <br/> floodfill(x,y,5); <br/> gettime(&t); <br/> if(t.ti_min!=m) <br/> { <br/> setcolor(0); <br/> line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180 <br/> ))); <br/> circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180)) <br/> ,10); <br/> line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h <br/> -((m/2)*(M_PI/180)))); <br/> circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-( <br/> (m/2)*(M_PI/180))),10); <br/> } <br/> if(t.ti_hour>12) <br/> t.ti_hour=t.ti_hour-12; <br/> if(t.ti_hour<4) <br/> h=abs(t.ti_hour-3); <br/> else&n<br/> bsp; <br/> h=15-t.ti_hour; <br/> m=t.ti_min; <br/> if(t.ti_min<=15) <br/> thetamin=(15-t.ti_min)*6; <br/> else <br/> thetamin=450-t.ti_min*6; <br/> if(t.ti_sec<=15) <br/> thetasec=(15-t.ti_sec)*6; <br/> else <br/> thetasec=450-t.ti_sec*6; <br/> setcolor(4); <br/> line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h <br/> -((m/2)*(M_PI/180)))); <br/> circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-( <br/> (m/2)*(M_PI/180))),10); <br/> line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180 <br/> ))); <br/> circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180)) <br/> ,10); <br/> setcolor(15); <br/> line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180 <br/> ))); <br/> delay(1000); <br/> setcolor(0); <br/> line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180 <br/> ))); <br/> } <br/> } </p><p> 该程序已在Turbo C++3.0中通过编译. |
|