这段程序看不懂,高手们能给加个注释嘛?

ecke 2003-10-08 10:38:54
#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=VGAHI;
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();
}
前面三个define定义那不太懂,还有程序核心部分也不太懂,谢谢拉
...全文
109 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lpc196196 2003-10-09
  • 打赏
  • 举报
回复
水平是差点,
chenzhengxi001(czx) 老兄的细心让人钦佩
chenzhengxi001 2003-10-09
  • 打赏
  • 举报
回复
#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);//把前面的带入不是得x,y吗?line(300,240,x,y)///
line(,,,)是个画线函数//////这就不用说了
////////////////////////
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) //i是5的倍数
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=VGAHI;//色之显示器
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);//用宏了line(300,240,X(150,h,30),Y(150,h,30));
setcolor(14);////这就不用说了
d(170,m,6);//up
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();//关闭图
}
//先把各个函数弄清,摘画留尘图
//加油啊
hdqqq 2003-10-08
  • 打赏
  • 举报
回复
define都看不懂,你c怎么学的?
playboyxp 2003-10-08
  • 打赏
  • 举报
回复
就拿这句说吧
#define X(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300;
define就是把后面的东西按原样拷贝到X(a,b,c)的地方
就是用x=a*cos(b*c*pi/180-pi/2)+300代替X(a,b,c)
anotherkaoyan 2003-10-08
  • 打赏
  • 举报
回复
别好高务远了
先把基础打扎实了再说

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧