heres a code for boundary filling
my doubt is how the control is going from one fill_right function to other -
#include<stdio.h>
-
#include<conio.h>
-
#include<graphics.h>
-
#include<dos.h>
-
-
void fill_right(x,y)
-
int x , y ;
-
{
-
if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED))
-
{
-
putpixel(x,y,RED);
-
fill_right(++x,y);
-
delay(1);
-
x = x - 1 ;
-
fill_right(x,y-1);
-
fill_right(x,y+1);
-
}
-
delay(1);
-
}
-
-
-
void fill_left(x,y)
-
int x , y ;
-
{
-
if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED))
-
{
-
putpixel(x,y,RED);
-
-
fill_left(--x,y);
-
x = x + 1 ;
-
fill_left(x,y-1);
-
fill_left(x,y+1);
-
}
-
delay(1);
-
}
-
-
-
void main()
-
{
-
int x,y,n,i;
-
int gd=DETECT,gm;
-
clrscr();
-
-
initgraph(&gd,&gm,"c:\\tc\\bgi");
-
-
-
-
/*- draw object -*/
-
-
line (50,50,200,50);
-
line (200,50,200,100);
-
line (200,100,50,100);
-
line (50,100,50,50);
-
-
/*- set seed point -*/
-
x = 125; y = 75;
-
-
fill_right(x,y);
-
fill_left(x-1,y);
-
-
getch();
-
}
-
-
please help me......thanks a lot
1 1217
The wasiest way to see how recursion works is to use Post-It sheets.
When you call the fill function, take a Post-It and write down the names and values of the variables.
Next, go through the code a line at a time and make chnages to the variables based on the code.
When you get to a call to the fill function inside the fill function, stop writing on the Post-It and start a new one for the new call.
Now go back to the start of the fill function and write doiwn the values as you did before but these will be the values from the second call.
Step through the code again and if you get to another call to the fill function start another Post-It.
When you finally get to a return in the fill function, you go back to the previous Post-It and resume stepping through the fill function after the place where it was called.
Eventually, you will work your way back to main().
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tersia Ehlert |
last post by:
Hi
I have an .NET web application where I redirect a page on submit to a blank page where the code below runs client side.
I want to, with this code, refresh two frames - the one my page was...
|
by: mvirta |
last post by:
How can I verify that AWE is actually working? The server is SQL 2000
EE on W2KAS with the /pae switch.
I've allocated 5000Mb (5Gb) for SQL but Performance monitor says the
working set for the...
|
by: dBNovice |
last post by:
Hi all, I am reusing code that was used in a previous copy of the DB.
I am trying to extract data from other tables, queries and a form and
put it in a table. The code was used previously and...
|
by: javakid |
last post by:
Hi
Following form validatioin code is working fine on IE but not working on Mozilla Firefox V2.
Can any body suggest?
Regards
<script ="JAVASCRIPT" type="text/javascript">...
|
by: n.torrey.pines |
last post by:
Hi
I work with a nested tree-like data structure template (that happens
to be a tuple of vectors of tuples of trees of something, with
different tuple elements having different types)
I need...
|
by: rajasree |
last post by:
Hi all,
am doing a project in PHP. my javascript code is working properly in ie. But its not working in firefox. Please help me
my code is as follows;
<script language="javascript"...
|
by: xmail123 |
last post by:
Why does this code work?
I am new to C# and have been studying this piece of code. It loops
through an Adjacency Matrix table to populate a tree view. I have two
questions about why this code...
|
by: sateeshchandrasanga |
last post by:
Hi All,
My HTML code is working fine in Firefox.But its not displaying any thing in IE.Can you help me in this problem.And in Google crown its displaying but not properly.
...
|
by: Barak, Ron |
last post by:
Thanks Gabriel,
Okay, I get it: I was under the impression that the format check would be done on the open.
Bye,
Ron.
-----Original Message-----
From: Gabriel Genellina
Sent: Thursday,...
|
by: kkshansid |
last post by:
i hav 2 tables
1 town containing 338 data
2 address containing 500 data
i want to display town then related address
then again town then related address
and so on
but my code not working...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |