时钟程序
#include<graphics.h> #include<math.h>
#include<dos.h>
#define PI 3.1415926
#define mid_x 320
#define mid_y 240
int main()
{ int graphdriver=DETECT,graphmode;
int end_x,end_y;
struct time curtime;
float th_hour,th_min,th_sec;
initgraph(&graphdriver,&graphmode,"C:\\TC2");
setbkcolor(BLACK);
while(!kbhit(0))
{ setcolor(GREEN);
circle(mid_x,mid_y,180);
circle(mid_x,mid_y,150);
circle(mid_x,mid_y,1);
gettime(&curtime);
th_sec=(float)curtime.ti_sec*0.1047197551;
th_min=(float)curtime.ti_min*0.1047197551+th_sec/60.0;
th_hour=(float)curtime.ti_hour*0.5235987755+th_min/12.0;
end_x=mid_x+70*sin(th_hour);
end_y=mid_y-70*cos(th_hour);
setcolor(RED);
line(mid_x,mid_y,end_x,end_y);
end_x=mid_x+110*sin(th_min);
end_y=mid_y-110*cos(th_min);
setcolor(RED);
line(mid_x,mid_y,end_x,end_y);
end_x=mid_x+140*sin(th_sec);
end_y=mid_y-140*cos(th_sec);
setcolor(RED);
line(mid_x,mid_y,end_x,end_y);
line(140,240,160,240);
line(320,60,320,80);
line(500,240,480,240);
line(320,420,320,400);
line(410,395.7,400,378.4);
line(475.7,330,458.4,320);
line(475.7,150,458.4,160);
line(410,84.3,400,101.6);
line(230,84.3,240,101.6);
line(164.3,150,181.6,160);
line(164.3,330,181.6,320);
line(230,395.7,240,378.4);
sleep(BLUE);
cleardevice();
}
closegraph();
return 0;
}
搜索更多相关的解决方案:
时钟
----------------解决方案--------------------------------------------------------
编译不了啊?
struct time是什么?gettime(&curtime); 又是什么函数,编译器说未定义 ----------------解决方案--------------------------------------------------------
要是加点注释的话那对我这样的刚接触C语言的就更好了
----------------解决方案--------------------------------------------------------
谁能加个注释啊
----------------解决方案--------------------------------------------------------