用C语言实现的闹钟程序#include#include#include#include#includevoidmain(){intgd=DETECT,gm;intx=320,y=240,r=200,i,h,m,s,thetamin,thetasec;structtimet;charn[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"};initgraph(&gd,&gm,"g:\\物亩tc\\bgi");//图形驱动器路径,根据自己的系统更换。circle(x,y,210);setcolor(4);settextstyle(4,0,5);for(i=0;i<12;i++){if(i!=3)outtextxy(x+(r-14)*cos(M_PI/6*i)-10,y-(r-14)*sin(M_PI/6*i)-26,n[i]);elseouttextxy(x+(r-14)*cos(M_PI/6*i)-20,y-(r-14)*sin(M_PI/6*i)-26,n[i]);}gettime(&t);printf("Thecurrenttimeis:%2d:%02d:%02d.%02d\n",t.ti_hour,t.ti_min,t.ti_sec,t.ti_hund);while(!kbhit()){setcolor(5);setfillstyle(1,5);circle(x,y,10);floodfill(x,y,5);gettime(&t);if(t.ti_min!=m){setcolor(0);line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180)));circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180)),10);line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h-((m/2)*(M_PI/180))));circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-((m/2)*(M_PI/180))),10);}if(t.ti_hour>12)t.ti_hour=t.ti_hour-12;if(t.ti_hour<核腔4)h=abs(t.ti_hour-3);else h=15-t.ti_hour;m=t.ti_min;if(t.ti_min<=15)thetamin=(15-t.ti_min)*6;elsethetamin=450-t.ti_min*6;if(t.ti_sec<=15)thetasec=(15-t.ti_sec)*6;elsethetasec=450-t.ti_sec*6;setcolor(4);line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h-((m/2)*(M_PI/罩氏森180))));circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-((m/2)*(M_PI/180))),10);line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180)));circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180)),10);setcolor(15);line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180)));delay(1000);setcolor(0);line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180)));}}该程序已在TurboC++3.0中通过编译.
相关文章
-
电脑总是显示出现一个问题,导致程序停止正常工作,请关闭该程序!这是怎么回事?
2023-05-08 19:17 阅读(589) -
应用程序是什么意思 应用程序的意思介绍
2023-05-08 17:01 阅读(630) -
cmdagent.exe 程序是干什么的?
2023-05-08 15:08 阅读(569)
1 怎么解决显示器驱动程序已停止响应,并且已恢复
627 阅读
2 求《java程序员面试宝典》全文免费下载百度网盘资源,谢谢~
576 阅读
3 用office打开文件时显示向程序发送命令时出现错误怎么解决?
603 阅读