hi everybody,

i have a function paint (x,y) and i have to paint a city. (it is not a regular shape)
Lets Assume this fuction paint(x,y) is painting point by point ok!!

so could anybody give the ReCursive C code to paint the city

Note:I know the coordinates of the border we can think it as a matrix data structure

2. Well, since I don't know how your code is...I'll just kinda give you some pseudo code.

Code:
```int height=20, width=50;

for (int i=0; i<height; i++){
for (int j=0; j<width; j++){
paint(j,i);
}
}```
Hope this is kind of the idea you were looking for. Again, it's just pseudo code, really...but it illustrates the idea. It will fill in the first row horizontally from left to right, then move down to the next row and fill that one in. The outer for loop doesn't increase and move to a new row until the inner loop has executed throughout the entire width of city.

Oh, and that's not recursive...but it should be okay.

3. Originally Posted by porsuk
hi everybody,

i have a function paint (x,y) and i have to paint a city. (it is not a regular shape)
Lets Assume this fuction paint(x,y) is painting point by point ok!!

so could anybody give the ReCursive C code to paint the city

Note:I know the coordinates of the border we can think it as a matrix data structure

Hi !
Isn't so harrashing to pick a coordinate and put it as a pixel , and are you sure you will point all the pixel as a picture ?
Why don't you scan a picture- change the JPG picture to binary code and transfer it into your C program.
Try it
Bye

4. You need to describe your problem in much more detail. What is this 'city' of which you speak? What describes the 'city'?

5. You paint a point x,y
You then examine points x-1,y x+1,y, x,y-1 and x,y+1 to see if you've reached a border.
If you haven't, recursively call yourself with x-1,y etc

Note: This algorithm sucks, but it is what you asked for.

If you want a serious answer (not a homework answe), then look up the scanline fill algorithm at a google prompt near you.

Popular pages Recent additions