求高手解决VC画直线代码,编译没错~~~
#include"graphics.h"void MidpointLine(int x0,int y0,int x1,int y1,int color)
{
int a,b,dalte1,dalte2,d,x,y;
a=y0-y1;
b=x1-x0;
dalte1=a+a;
dalte2=a+a+b+b;
d=a+a+b;
x=x0;
y=y0;
putpixel(x,y,color);
while(x0<x1)
{
if(d<0)
{
x++;
y++;
d+=dalte2;
}
else
{
x++;
d+=dalte1;
}
}
putpixel(x,y,color);
}/*中点画线法函数*/
main()
{
int a,b,c,d,e;
int graphdriver=DETECT;
int graphmode=0;
initgraph(&graphdriver,&graphmode," ");
cleardevice();
a=0;
b=0;
c=300;
d=200;
e=2;
MidpointLine(a,b,c,d,e);
getch();
closegraph();
}
[ 本帖最后由 火男 于 2010-12-5 21:24 编辑 ]