Recursive Fill (Please Help

When you press return, it's supposed to go to a new row, but I'm a little confused and need help. Here are instructions.
Write a program that gets as an input:
• A perimeter (boundary) of a “closed” shape, such as an ellipse, circle, etc,.
• Coordinates of an interior point.
The program should fill in a recursive way the area (enclosed by) this shape from the given interior point without exceeding the boundary of this shape. For example if the

The input will include:
• m lines, each including n characters. If the character read is not a space, the character belongs
to the boundary of the shape.
• Two numbers that specify the coordinates, namely the row and column indices of the point from which the program is supposed to start filling the shape.

This is what I have so far, any help would be greatly appreciated, thanks
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "strlib.h"
#define max 30

void prep(char shape[max][max], int b1, int b2)
{
     int i, c;
     for(i=0;i<b2;i++)
     {
                      for(c=0;c<b1;c++)
                      {
                                       if(shape[i][c]==42) break;
                                       else(shape[i][c]=35);
                                       }
                                       }
     for(i=b2-1;i>=0;i--)
     {
                      for(c=b1-1;c>=0;c--)
                      {
                                       if(shape[i][c]==42) break;
                                       else(shape[i][c]=35);
                                       }
                                       }
     for(i=0;i<b1;i++)
     {
                      for(c=0;c<b2;c++)
                      {
                                       if(shape[c][i]==42) break;
                                       else(shape[c][i]=35);
                                       }
                                       }
     for(i=b1-1;i>=0;i--)
     {
                      for(c=b2-1;c>=0;c--)
                      {
                                       if(shape[c][i]==42) break;
                                       else(shape[c][i]=35);
                                       }
                                       }
                                       }
void getArray(char shape[max][max], int b1, int b2)
{
     int n, t;
     char b;
     printf("Enter your shape's boundaries, and when you have reached the end of your row press enter. Repeat until shape is completed\n");
     for(n=0;n<b2;n++)
     {
                      for(t=0;t<=b1;t++)
                      {
                                       shape[n][t]=getchar();
                                       }
                                       }                          
                                       }
void fill(char shape[max][max], int r, int c, int b1, int b2)
{
        int i, n;
          if ((shape[r][c]==42)||(r<=0)||(c<=0)||(r>=b2-1)||(c>=b1-1)||(shape[r][c]==35))
          {
             return;

        
            }             
           else 
            
           { shape[r][c]=42;
                      i=r-1;
                      while (i<=r+1)
                           {   n=c-1;
                              while (n<=c+1)
                                     {
                                     
                                         fill(shape,i,n, b1, b2);
                                     
                                        n=n+1;}
                             i=i+1; }
                }
                                             
                                                 }

void displayArray1(char shape[max][max], int b1, int b2)
{
     int i, n;
     for(i=0;i<b2;i++)
          {
                  for(n=0;n<=b1;n++) 
                  {            
                  printf("%c", shape[i][n]);
                                    
                                     }
                                     }
                                     printf("\n");
                                     }
 void displayArray2(char shape[max][max], int b1, int b2)
{
     int i, n;
     for(i=0;i<b2;i++)
          {
                  for(n=0;n<=b1;n++) 
                  {  
                                     if (shape[i][n]==35) printf(" ");          
                   else printf("%c", shape[i][n]);
                                    
                                     }
                                     }
                                     printf("\n");
                                     }
main()
{
      int s, r, c, b1, b2;
      char shape[max][max],elli[max][max];
      printf("Enter the number of rows of your shape\n");
      b2=GetInteger();
      printf("Enter the number of colums of your shape\n");
      b1=GetInteger();
      getArray(shape, b1, b2);
      prep(shape, b1, b2);
      printf("The modified shape you have entered is \n");
      displayArray1(shape, b1, b2);
      printf("Enter the row of the point inside of the shape you entered\n");
      r=GetInteger();
      printf("Enter the colum of the point inside of the shape you entered\n");
      c=GetInteger();
      fill(shape, r, c, b1, b2);
      displayArray2(shape, b1, b2);
      getchar();
      }
Topic archived. No new replies allowed.