桌面闹钟:一个桌面闹钟源程序



/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
/*###############CLOCK.C###############*/
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
#<graphics.h>
#<stdlib.h>
#<stdio.h>
#<conio.h>
#<dos.h>
#<math.h>
#X(a,b,c)x=a*cos(b*c*pi/180.0-pi/2)+midx;
#Y(a,b,c)y=a*sin(b*c*pi/180.0-pi/2)+midy;
#d(a,b,c)X(a,b,c);Y(a,b,c);line(midx,midy,x,y)
#pi3.1415926
void(void)
{
floatx,y;
gdriver=DETECT,gmode,errorcode;
midx,midy,l,x1,x2,y1,y2;
radius=100;
structtimet;
floath,m,s;
i;
/*initializegraphics*/
initgraph(&gdriver,&gmode,"");
/*readresultofinitialization*/
errorcode=graphresult;
(errorcode!=grOk)/*anerroroccurred*/
{
prf("Graphicserror:%s\\n",grapherrormsg(errorcode));
prf("Pressanykeytohalt:");
getch;
exit(1);/*terminatewithanerrorcode*/
}
writemode(1);/*shezhiweugaixingshi,zuoyongshi*/
/*meihuayicixianjiouqingchuyici*/
/*yixiashidedaoyuanxizuobiao*/
midx=getmaxx/2;
midy=getmaxy/2;
bkcolor(1);/*beijingyanseweiBLUE*/
color(2);/*shezhilimiancircledecolor*/
circle(midx,midy,radius);/*drawthelimiancircle*/
color(5);/*shezhiwaimiancircledecolor*/
circle(midx,midy,radius+5);/*drawwaimiandecircle*/
color(3);/*shezhiyuanxindecolor*/
circle(midx,midy,2);/*drawthecenterofthecircle*/
/*thefollowinglinesaredrawingtheKE_DUpan*/
for(i=0;i<60;i)
{
(i%50)l=15;
l=5;
x1=100*cos(i*6*pi/180)+midx;
y1=100*sin(i*6*pi/180)+midy;
x2=(100-l)*cos(i*6*pi/180)+midx;
y2=(100-l)*sin(i*6*pi/180)+midy;
line(x1,y1,x2,y2);
}

/*getthetime*/
gettime(&t);
h=t.ti_hour;
m=t.ti_min;
s=t.ti_sec;
/*drawthehour_hand*/
color(7);
d(60,(h+(float)m/60),30);/*这行是很关键有了这行时针就可以随着*/
/*分针移动而随时移动了从而改变了原来只有*/
/*到整点时针才能变动局限*/

/*drawthemin_hand*/


color(14);
d(75,m,6);

/*drawthesec_hand*/
color(4);
d(90,s,6);
while(!kbhit)
{
while(t.ti_secs)
gettime(&t);
gotoxy(1,1);
prf("Thecurrenttimeis:%2d:%02d:%02d.%02d",
t.ti_hour,t.ti_min,t.ti_sec,t.ti_hund);
sound(150);
delay(100);
sound(300);
nosound;
color(4);
d(90,s,6);
s=t.ti_sec;
d(90,s,6);
(t.ti_min!=m)
{
color(14);
d(75,m,6);
m=t.ti_min;
d(75,m,6);
}
color(7);
d(60,h+(float)m/60.0,30);
h=(float)t.ti_hour;
d(60,h+(float)m/60.0,30);
(t.ti_hour!=()h)
{
color(7);
d(60,h,30);
h=t.ti_hour;
d(60,h,30);
sound(500);
delay(200);
nosound;
sound(1000);
delay(100);
nosound;
}
}
getch;
closegraph;
}
Tags:  桌面闹钟程序 电脑桌面闹钟 桌面小闹钟 桌面闹钟

延伸阅读

最新评论

  1. 怎么用这个闹钟啊,在电脑上

发表评论