#include<time.h> #include<conio.h> #include<iostream.h> #include<graphics.h> #include<math.


void line_dda(float x1,float y1,float x2,float y2) { float dx,dy,x=x1,y=y1,m; int i; dx=x2-x1; dy=y2-y1; if(abs(dx)>=abs(dy)) m=abs(dx); else m=abs(dy); putpixel((int)x,(int)y,15); for(i=1;i<=m;i++) { x=x+dx/m; y=y+dy/m; putpixel((int)x,(int)y,15); } } void main() { clock_t start,end; float x1,x2,y1,y2; int gd=DETECT,gm=DETECT; initgraph(&gd,&gm,"f:\\tc\\bgi"); cout<<"Enter 1st end point of line(x1,y1) ";

y2).start)/CLK_TCK.x2. cin>>x2>>y2. } . getch(). end = clock(). start=clock(). closegraph().y2) ". line_dda(x1. cout<<"The time for DDA method was" <<(end . cout<<"Enter 2nd end point of line(x2.cin>>x1>>y1.y1.

Sign up to vote on this title
UsefulNot useful