源代码:#include#include#include#include#definePI3.1415926/*定义常量*/#defineUP0x4800/*上移↑键:修改时间*/#defineDOWN0x5000/*下移↓键:修改时间*/#defineESC0x11b/*ESC键:退出系统*/#defineTAB0xf09/*TAB键:移动光标*//*函数声明*/intkeyhandle(int,int);/*键盘按键判断,并调用相关函数处理*/inttimeupchange(int);/*处理上移按键*/inttimedownchange(int);/*处理下移按键*/intdigithour(double);/*将double型的小时数转换成int型*/intdigitmin(double);/*将double型的分钟数转换成int型*/intdigitsec(double);/*将double型的秒钟数转换成int型*/voiddigitclock(int,int,int);/*在指定位置显示时钟或分钟或秒钟数*/voiddrawcursor(int);/*绘制一个光标*/voidclearcursor(int);/*消除前一个光标*/voidclockhandle();/*时钟处理*/doubleh,m,s;/*全局变量:小时,分,秒*/doublex,x1,x2,y,y1,y2;/*全局变量:坐标值*/structtimet[1];/*定义一个time结构类型的数组*/main(){intdriver,mode=0,i,j;driver=DETECT;/*自动检测显示设备*/initgraph(&driver,&mode,"");/*初始化图形系统*/setlinestyle(0,0,3);/*设置当前画线宽度和类型:设置三点宽实线*/setbkcolor(0);/*用调色板设置当前背景颜色*/setcolor(9);/*设置当前画线颜色*/line(82,430,558,430);line(70,62,70,418);line(82,50,558,50);line(570,62,570,418);line(70,62,570,62);line(76,56,297,56);line(340,56,564,56);/*画主体框架的边直线*//*arc(intx,inty,intstangle,intendangle,intradius)*/arc(82,62,90,180,12);arc(558,62,0,90,12);setlinestyle(0,0,3);arc(82,418,180,279,12);setlinestyle(0,0,3);arc(558,418,270,360,12);/*画主体框架的边角弧线*/setcolor(15);outtextxy(300,53,"CLOCK");/*显示标题*/setcolor(7);rectangle(342,72,560,360);/*画一个矩形,作为时钟的框架*/setwritemode(0);/*规定画线的方式。
mode=0,则表示画线时将所画位置的原来信息覆盖*/setcolor(15);outtextxy(433,75,"CLOCK");/*时钟的标题*/setcolor(7);line(392,310,510,310);line(392,330,510,330);arc(392,320,90,270,10);arc(510,320,270,90,10);/*绘制电子动画时钟下的数字时钟的边框架*//*绘制数字时钟的时分秒的分隔符*/setcolor(5);for(i=431;i<=470;i+=39)for(j=317;j<=324;j+=7){setlinestyle(0,0,3);circle(i,j,1);/*以(i,y)为圆心,1为半径画圆*/}setcolor(15);line(424,315,424,325);/*在运行电子时钟前先画一个光标*//*绘制表示小时的圆点*/for(i=0,m=0,h=0;i<=11;i++,h++){x=100*sin(
1