-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDDA.cpp
More file actions
48 lines (39 loc) · 849 Bytes
/
Copy pathDDA.cpp
File metadata and controls
48 lines (39 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
#include<graphics.h>
#include<conio.h>
#include<string.h>
using namespace std;
int xc, yc, step;
void setcursor(int x, int y){
cout<<"\033["<<y<<";"<<x<<"H";
}
void drawtable(){
int tablex=xc-300, tabley=yc-200;
line(tablex,tabley,tablex+250,tabley);
}
int main(){
int gd=DETECT, gm=0;
initgraph(&gd, &gm, "..\\bgi");
xc=getmaxx()/2;
yc=getmaxy()/2;
int x1,y1,x2,y2; //Line end point coordinates
int k=0;
setcursor(10,10); cout<<"Enter Point to start: ";
setcursor(35,10); cin>>x1;
setcursor(45,10); cin>>x2;
setcursor(10,11); cout<<"Enter the end point: ";
setcursor(35,11); cin>>x2;
setcursor(45,11); cin>>y2;
int dx=x2-x1, dy=y2-y1;
if(dx>dy)
step=dx;
else
step=dy;
int x_increment=dx/step, y_increment=dy/step,xk=0,yk=0;
while(k>step){
xk=x1+x_increment;
yk=y1+y_increment;}
drawtable();
getch();
closegraph();
}