主题:求大神帮我解释这段代码。非常感谢!!!!!!!
#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);
for(i=0;i<60;i++)
{
if(i%5==0)
l=15;
else
l=5;
x1=200*sin(i*6*pi/180)+300;
y1=200*cos(i*6*pi/180)+240;
x2=(200-l)*sin(i*6*pi/180)+300;
y2=(200-l)*cos(i*6*pi/180)+240;
line(x1,y1,x2,y2);
}
}
main()
{
int x,y,i,k=1;
unsigned char h,m,s;
int o,p,q;
float n;
struct time t[1];
struct date d[1];
int gdriver=DETECT,gmode;
registerbgidriver(EGAVGA_driver);
initgraph( &gdriver, &gmode,"c:\\tc");
for(i=0;i<=6;i++)
{
settextstyle(TRIPLEX_FONT,HORIZ_DIR,i); /*控制输出字符的字体,方向,大小*/
cleardevice();
settextjustify(1,1);
outtextxy(300,80,"12") ;
outtextxy(220,100,"11");
outtextxy(160,160,"10");
outtextxy(140,230,"9");
outtextxy(160,310,"8");
outtextxy(220,370,"7");
outtextxy(300,390,"6");
outtextxy(380,370,"5");
outtextxy(430,310,"4");
outtextxy(460,230,"3");
outtextxy(430,160,"2");
outtextxy(380,100,"1");
}
init();
setwritemode(1);
if(k!=0)
{
getdate(d);
o=d[0].da_year;
p=d[0].da_mon;
q=d[0].da_day;
gettime(t);
h=t[0].ti_hour;
m=t[0].ti_min;
s=t[0].ti_sec;
}
setcolor(7);
n=(float)h+(float)m/60;
d(150,n,30);
setcolor(14);
d(170,m,6);
setcolor(4);
d(190,s,6);
while(!kbhit())
{
while(t[0].ti_sec==s)
gettime(t);
gotoxy(44,18);
printf("\b\b\b\b\b\b\b\b\b");
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();
}
if(s<10) /*用字符的形式输出时间*/
{ if(m<10)
printf("%u:0%u:0%u",h,m,s);
else
printf("%u:%u:0%u",h,m,s);
}
else
{ if(m<10)
printf("%u:0%u:%u",h,m,s);
else
printf("%u:%u:%u",h,m,s);
}
gotoxy(34,19);
printf("%d年%d月%d日",o,p,q);
printf("\b\b\b\b\b\b\b\b\b");
}
getch();
closegraph();
}
其中
circle(300,240,200);
circle(300,240,205);
circle(300,240,5); 是什么意思?
#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);
for(i=0;i<60;i++)
{
if(i%5==0)
l=15;
else
l=5;
x1=200*sin(i*6*pi/180)+300;
y1=200*cos(i*6*pi/180)+240;
x2=(200-l)*sin(i*6*pi/180)+300;
y2=(200-l)*cos(i*6*pi/180)+240;
line(x1,y1,x2,y2);
}
}
main()
{
int x,y,i,k=1;
unsigned char h,m,s;
int o,p,q;
float n;
struct time t[1];
struct date d[1];
int gdriver=DETECT,gmode;
registerbgidriver(EGAVGA_driver);
initgraph( &gdriver, &gmode,"c:\\tc");
for(i=0;i<=6;i++)
{
settextstyle(TRIPLEX_FONT,HORIZ_DIR,i); /*控制输出字符的字体,方向,大小*/
cleardevice();
settextjustify(1,1);
outtextxy(300,80,"12") ;
outtextxy(220,100,"11");
outtextxy(160,160,"10");
outtextxy(140,230,"9");
outtextxy(160,310,"8");
outtextxy(220,370,"7");
outtextxy(300,390,"6");
outtextxy(380,370,"5");
outtextxy(430,310,"4");
outtextxy(460,230,"3");
outtextxy(430,160,"2");
outtextxy(380,100,"1");
}
init();
setwritemode(1);
if(k!=0)
{
getdate(d);
o=d[0].da_year;
p=d[0].da_mon;
q=d[0].da_day;
gettime(t);
h=t[0].ti_hour;
m=t[0].ti_min;
s=t[0].ti_sec;
}
setcolor(7);
n=(float)h+(float)m/60;
d(150,n,30);
setcolor(14);
d(170,m,6);
setcolor(4);
d(190,s,6);
while(!kbhit())
{
while(t[0].ti_sec==s)
gettime(t);
gotoxy(44,18);
printf("\b\b\b\b\b\b\b\b\b");
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();
}
if(s<10) /*用字符的形式输出时间*/
{ if(m<10)
printf("%u:0%u:0%u",h,m,s);
else
printf("%u:%u:0%u",h,m,s);
}
else
{ if(m<10)
printf("%u:0%u:%u",h,m,s);
else
printf("%u:%u:%u",h,m,s);
}
gotoxy(34,19);
printf("%d年%d月%d日",o,p,q);
printf("\b\b\b\b\b\b\b\b\b");
}
getch();
closegraph();
}
其中
circle(300,240,200);
circle(300,240,205);
circle(300,240,5); 是什么意思?