| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 848 人关注过本帖
标题:时钟程序
取消只看楼主 加入收藏
大白免
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2008-1-1
收藏
 问题点数:0 回复次数:0 
时钟程序
#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;
}


搜索更多相关主题的帖子: 时钟 
2008-01-02 17:20
快速回复:时钟程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.118635 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved