| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1335 人关注过本帖
标题:[求助]这段时钟代码请给我讲解一下
只看楼主 加入收藏
Lincoo
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2004-7-5
收藏
 问题点数:0 回复次数:7 
[求助]这段时钟代码请给我讲解一下

自己看了 不过还是想让人给讲一下 该注意什么 如果更好该怎样等等

#include<graphics.h> #include<math.h> #include<dos.h> #define pi 3.1415926 #define X(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300; #define Y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240; #define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y) void init() {int i,l,x1,x2,y1,y2; setbkcolor(1); circle(300,240,200); circle(300,240,205); circle(300,240,5); for(i=0;i<60;i++) {if(i%5==0) l=15; else l=5; x1=200*cos(i*6*pi/180)+300; y1=200*sin(i*6*pi/180)+240; x2=(200-l)*cos(i*6*pi/180)+300; y2=(200-l)*sin(i*6*pi/180)+240; line(x1,y1,x2,y2); } } main() { int x,y; int gd=VGA,gm=2; unsigned char h,m,s; struct time t[1]; initgraph(&gd,&gm,"d:\\tc"); init(); setwritemode(1); gettime(t); h=t[0].ti_hour; m=t[0].ti_min; s=t[0].ti_sec; setcolor(7); d(150,h,30); setcolor(14); d(170,m,6); setcolor(4); d(190,s,6); while(!kbhit()) {while(t[0].ti_sec==s) gettime(t); sound(400); delay(70); sound(200); delay(30); nosound(); setcolor(4); d(190,s,6); s=t[0].ti_sec; d(190,s,6); if (t[0].ti_min!=m) { setcolor(14); d(170,m,6); m=t[0].ti_min; d(170,m,6); } if (t[0].ti_hour!=h) { setcolor(7); d(150,h,30); h=t[0].ti_hour; d(150,h,30); sound(1000); delay(240); nosound(); delay(140); sound(2000); delay(240); nosound(); } } getch(); closegraph(); }

搜索更多相关主题的帖子: 时钟 circle define include 代码 
2004-12-02 22:12
ysfabm
Rank: 1
等 级:新手上路
威 望:1
帖 子:274
专家分:0
注 册:2004-11-9
收藏
得分:0 

我在VC++6.0下调试这个程序不能通过出现这相错误:

fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory Error executing cl.exe.


精诚所至,
       金石为开!
      PLM技术社区: [url=http://www.]www.[/url] 最专业的PLM技术讨论社区。
2004-12-03 08:07
时空之蕊
Rank: 2
等 级:新手上路
威 望:3
帖 子:691
专家分:0
注 册:2004-10-31
收藏
得分:0 

呵呵!你这个要用tc来运行!还有在tc中要设置库的设置让他包含图形库


我渴望掌控时空的核心——用最先进的技术,打造无比美丽的世界!
2004-12-03 08:42
时空之蕊
Rank: 2
等 级:新手上路
威 望:3
帖 子:691
专家分:0
注 册:2004-10-31
收藏
得分:0 
vc中我还不清楚怎么来调用图形库

我渴望掌控时空的核心——用最先进的技术,打造无比美丽的世界!
2004-12-03 08:43
Lincoo
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2004-7-5
收藏
得分:0 
wintc1.91 编译成功

我就是个种田的,只有两亩地,爱咋咋地~!
2004-12-03 11:31
天使预备役
Rank: 2
等 级:论坛游民
威 望:3
帖 子:670
专家分:10
注 册:2004-4-6
收藏
得分:0 

#include<graphics.h> #include<math.h> #include<dos.h> #define pi 3.1415926//在使用宏定义的时候要注意该加的括弧一定要加上,不然就变味了(不是就题论题,在这可以用

//常量代替) #define X(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300; #define Y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240; #define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y) void init() {int i,l,x1,x2,y1,y2; setbkcolor(1);//最好在这注上1表示哪中颜色,以备自己清楚! circle(300,240,200);//画圆(x,y,r) circle(300,240,205); circle(300,240,5); for(i=0;i<60;i++) {if(i%5==0) l=15; else l=5; x1=200*cos(i*6*pi/180)+300; y1=200*sin(i*6*pi/180)+240; x2=(200-l)*cos(i*6*pi/180)+300; y2=(200-l)*sin(i*6*pi/180)+240; line(x1,y1,x2,y2); } } main() { int x,y; int gd=VGA,gm=2;//两个最好统一int gd=VGA,gm=VGAHI; unsigned char h,m,s; struct time t[1];//什么意思???1么??? initgraph(&gd,&gm,"d:\\tc");//注意""中表示的位置一定要正确! init(); setwritemode(1);//表示异或画线(两次同一位置画线,线被清除) gettime(t);//获得系统时间 h=t[0].ti_hour; m=t[0].ti_min; s=t[0].ti_sec; setcolor(7);//颜色设置 d(150,h,30); setcolor(14); d(170,m,6); setcolor(4); d(190,s,6); while(!kbhit())//判断是否有键盘操作 {while(t[0].ti_sec==s) gettime(t); sound(400);//铃声 delay(70);//控制响铃的时间 sound(200); delay(30); nosound();//关闭铃声 setcolor(4); d(190,s,6); s=t[0].ti_sec; d(190,s,6); if (t[0].ti_min!=m) { setcolor(14); d(170,m,6); m=t[0].ti_min; d(170,m,6); } if (t[0].ti_hour!=h) { setcolor(7); d(150,h,30); h=t[0].ti_hour; d(150,h,30); sound(1000); delay(240); nosound(); delay(140); sound(2000); delay(240); nosound(); } } getch(); closegraph();//关闭图形模式,注意这一点! }


差点把你忘了...
2004-12-03 14:05
Lincoo
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2004-7-5
收藏
得分:0 
非常感谢!

我就是个种田的,只有两亩地,爱咋咋地~!
2004-12-03 17:15
corrupt
Rank: 2
等 级:新手上路
威 望:3
帖 子:535
专家分:0
注 册:2004-9-29
收藏
得分:0 

这个程序 是不能在 vc 中运行的~~


2004-12-03 17:53
快速回复:[求助]这段时钟代码请给我讲解一下
数据加载中...
 
   



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

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