为什么DDA算法在c中实现错误?

时间:2019-05-03 15:40:16

标签: c algorithm dda

C:\ Users \ DENEGR \ AppData \ Local \ Temp \ cc6ZmWTj.o Untitled2.cpp :(。text + 0x1bc):未定义对putpixel' C:\Users\DENEGR\AppData\Local\Temp\cc6ZmWTj.o Untitled2.cpp:(.text+0x1e5): undefined reference to的引用' C:\ Users \ DENEGR \ AppData \ Local \ Temp \ cc6ZmWTj.o Untitled2.cpp :(。text + 0x1ff):对`closegraph'的未定义引用 C:\ t \ b \ collect2.exe [错误] ld返回1个退出状态

#include<graphics.h>
#include<math.h>
#include<conio.h>
int main()
{
int x0,y0,x1,y1,i=0;
float delx,dely,len,x,y;
int gr=DETECT,gm;
//initgraph(&gr,&gm,"C:\\t//b");
printf("\n****** DDA Line Drawing Algorithm ***********");
printf("\n Please enter the starting coordinate of x, y = ");
scanf("%d %d",&x0,&y0);
printf("\n Enter the final coordinate of x, y = ");
scanf("%d %d",&x1,&y1);
dely=abs(y1-y0);
delx=abs(x1-x0);

if(delx<dely)
{
len = dely;
}
else
{
len=delx;
}
delx=(x1-x0)/len;
dely=(y1-y0)/len;
x=x0+0.5;
y=y0+0.5;
do{
putpixel(x,y,3);
x=x+delx;
y=y+dely;
i++;
delay(30);
}while(i<=len);
closegraph();
return 0;
}

0 个答案:

没有答案