我在网上看到了这个程序码,看不懂,麻烦哪位c语言高手把下面这个程序每句的后面加个注释,感激不尽!谢谢
我在网上看到了这个程序码,看不懂,麻烦哪位高手把下面这个程序每句的后面加个注释,感激不尽!谢谢#include <dos.h>
#include <bios.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include "graphics.h"
#define R 15
void initgr(void)
{
int gd = DETECT, gm = 0;
initgraph(&gd, &gm, "D:\\TC20\\BGI");
}
void getmouse(int *x,int *y,int *key)
{
union REGS inregs,outregs;
inregs.x.ax=3;
int86(0x33,&inregs,&outregs);
*x=outregs.x.cx;
*y=outregs.x.dx;
*key=outregs.x.bx;
}
void visbilemouse()
{
union REGS inregs,outregs;
inregs.x.ax=0x01;
int86(0x33,&inregs,&outregs);
}
void mouse(int *x,int *y,int *z)
{
int a=0,b=0,c=0,a_old=0,b_old=0;
int *ball;
ball=malloc(imagesize(a,b,a+R,b+R));
getimage(a,b,a+R,b+R,ball);
while(c==0)
{
getmouse(&a,&b,&c);
if(a<0) a=0;
if(b<0) b=0;
if(a>getmaxx()-R) a=getmaxx()-R;
if(b>getmaxy()-R) b=getmaxy()-R;
if(a!=a_old || b!=b_old)
{
putimage(a_old,b_old,ball,0);
getimage(a,b,a+R,b+R,ball);
setcolor(GREEN);
setlinestyle(0,0,1);
line(a,b,a+R,b+R/2);
line(a,b,a+R/2,b+R);
line(a+R,b+R/2,a+R/2,b+R);
line(a+R*3/4,b+R*3/4,a+R,b+R);
}
a_old=a;b_old=b;
}
*x=a;*y=b;*z=c;
putimage(a,b,ball,0);
free(ball);
}
void main()
{
int x,y,z;
initgr();
visbilemouse();
do
{
setcolor(WHITE);
rectangle(175,8,220,25);
outtextxy(180,10,"exit");
mouse(&x,&y,&z);
if(z==1)
{
setlinestyle(0,0,1);
setcolor(12);
circle(x,y,1);
}
if(z==2)
{setfillstyle(1,BLACK);
bar(0,0,getmaxx(),getmaxy());
}
}while(x<175 || x>220 || y<8 || y>25);
closegraph();
}