Skip to content

Commit 3619f21

Browse files
authored
Merge pull request #6 from Sharmistha18/master
4
2 parents 93a4f85 + 40fc7c8 commit 3619f21

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

flood1.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include<stdio.h>
2+
#include<conio.h>
3+
#include<graphics.h>
4+
void breline(int,int,int,int);
5+
int main()
6+
{
7+
int gd=DETECT,gm;
8+
int x1,y1,xn,yn;
9+
10+
printf("enter the starting co-ordinates:");
11+
scanf("%d%d",&x1,&y1);
12+
printf("enter the end co-ordinates:");
13+
scanf("%d%d",&xn,&yn);
14+
initgraph(&gd,&gm,"");
15+
breline(x1,y1,xn,yn);
16+
17+
getch();
18+
return 0;
19+
20+
}
21+
22+
void breline(int x1,int y1,int xn,int yn)
23+
{
24+
int dx,dy,s,t,p;
25+
dx=xn-x1;
26+
dy=yn-y1;
27+
p=2*dy-dx;
28+
s=2*dy;
29+
t=2*(dy-dx);
30+
putpixel(x1,y1,RED);
31+
while(x1<xn)
32+
{
33+
x1++;
34+
if(p<0)
35+
{
36+
p=p+s;
37+
}
38+
else
39+
{
40+
y1++;
41+
p=p+t;
42+
}
43+
putpixel(x1,y1,RED);
44+
45+
}
46+
}

0 commit comments

Comments
 (0)