谁帮我看看这个bresenham直线算法程序不能运行
我写了一个bresenham直线算法程序,是多点的,但是输入端点坐标后没有结果,请哪位高手指教?#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
int main(void)
{
int gdriver=DETECT,gmode;
int sx;
int sy;
int i;
int x1;
int y1;
int x2;
int y2;
int dx;
int dy;
int t1;
int t2;
int g;
initgraph(&gdriver,&gmode,"C:\\tc");
printf("please input points of the line:\n");
scanf("%d,%d,%d,%d\n",&x1,&y1,&x2,&y2);
dx=fabs(x2-x1);
dy=fabs(y2-y1);
t1=2*dy;
t2=2*(dy-dx);
g=2*dy-dx;
if(x2<x1)
sx=-1;
else
sx=1;
if(y2<y1)
sy=-1;
else
sy=1;
setbkcolor(0);
cleardevice();
if(dx>dy)
{
if(dx>2*dy)
{
for(i=1;i<=(dx-dy);i++)
{
x1+=sx;
if(g<0)
{g+=t1;}
else
{y1+=sy;
putpixel(x1,y1,100);
x1+=sx;
g+=(t1+t2);}
}
putpixel(x1,y1,100);
}
else
{
for(i=1;i<=dy;i++)
{
putpixel(x1,y1,100);
x1+=sx;
if(g<0)
{putpixel(x1,y1,100);
x1+=sx;
y1+=sy;
g+=(t1+t2);}
else
{y1+=sy;
g+=t2;}
}
}
}
else
{
g=2*dx-dy;
t1=2*dx;
t2=2*dx-2*dy;
if(dy<2*dx)
{
for(i=1;i<=dx;i++)
{
putpixel(x1,y1,100);
y1+=sy;
if(g<0)
{putpixel(x1,y1,100);
x1+=sx;
g+=(t1+t2);}
else
{x1+=sx;
y1+=sy;
g+=t2;}
}
}
else
{
for(i=1;i<=(dy-dx);i++)
{
putpixel(x1,y1,100);
y1+=sy;
if(g<0)
{g+=t1;}
else
{x1+=sx;
putpixel(x1,y1,100);
y1+=sy;
g+=(t1+t2);}
}
}
}
getch();
closegraph();
return 0;
}