We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 93a4f85 + 40fc7c8 commit 3619f21Copy full SHA for 3619f21
flood1.c
@@ -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
44
45
46
0 commit comments