How do I make the end part stop printing and only print the filled shape?
In this program the user enters a shape with **** and then the program prints out a filled shape, filling it with *** and beginning the shape's filling at the point where the user indicated.
Thanks
Chris
#include "simpio.h"
#include <stdio.h>
#include "genlib.h"
#define size 50;
void GetArray(char arr[][50]);
void fill(char arr[][50], int row, int col);
void disp(char arr[][50]);
main()
{
char arr[50][50];
int row, col;
GetArray(arr);
printf("\nEnter row of interior point: ");
row = GetInteger();
printf("Enter column of interior point: ");
col = GetInteger();
fill(arr, row, col);
disp(arr);
getchar();
system("pause") ;
}
void GetArray(char arr[][50])
{
char input;
int i,j;
for(i=0;i<50;i+ +)
{
for(j=0;j<50;j+ +)
{
arr[i][j] = ' ';
}
}
printf("Enter the closed shape using asterisks and spaces. \nKeep the number of rows and columns under 50\n");
printf("To signal the end of the input, type '!'. \nUse the 'enter' key to move down rows\n\n");
i = 0;
j = 0;
while(TRUE)
{
input = getchar();
if(input == 'r')
i++;
else if(input == '!')
break;
else
{
arr[i][j] = input;
j++;
}
}
i=0;
j=0;
printf("\n\nThe input shape is:\n");
for(i=0;i<50;i+ +)
{
for(j=0;j<50;j+ +)
{
printf("%c",arr[i][j]);
}
}
}
void fill(char arr[][50], int row, int col)
{
if(arr[row][col]!=' '|| row>=50 || col>=50 || row<0 || col<0)
{}
else
{
arr[row][col] ='*';
fill(arr,row+1, col);
fill(arr,row-1,col);
fill(arr,row,co l+1);
fill(arr,row,co l-1);
}
}
void disp(char arr[][50])
{
int i,j;
printf("\nThe filled shape is:\n");
for(i=0;i<50;i+ +)
{
for(j=0;j<50;j+ +)
{
printf("%c",arr[i][j]);
}
printf("\n");
}
}
In this program the user enters a shape with **** and then the program prints out a filled shape, filling it with *** and beginning the shape's filling at the point where the user indicated.
Thanks
Chris
#include "simpio.h"
#include <stdio.h>
#include "genlib.h"
#define size 50;
void GetArray(char arr[][50]);
void fill(char arr[][50], int row, int col);
void disp(char arr[][50]);
main()
{
char arr[50][50];
int row, col;
GetArray(arr);
printf("\nEnter row of interior point: ");
row = GetInteger();
printf("Enter column of interior point: ");
col = GetInteger();
fill(arr, row, col);
disp(arr);
getchar();
system("pause") ;
}
void GetArray(char arr[][50])
{
char input;
int i,j;
for(i=0;i<50;i+ +)
{
for(j=0;j<50;j+ +)
{
arr[i][j] = ' ';
}
}
printf("Enter the closed shape using asterisks and spaces. \nKeep the number of rows and columns under 50\n");
printf("To signal the end of the input, type '!'. \nUse the 'enter' key to move down rows\n\n");
i = 0;
j = 0;
while(TRUE)
{
input = getchar();
if(input == 'r')
i++;
else if(input == '!')
break;
else
{
arr[i][j] = input;
j++;
}
}
i=0;
j=0;
printf("\n\nThe input shape is:\n");
for(i=0;i<50;i+ +)
{
for(j=0;j<50;j+ +)
{
printf("%c",arr[i][j]);
}
}
}
void fill(char arr[][50], int row, int col)
{
if(arr[row][col]!=' '|| row>=50 || col>=50 || row<0 || col<0)
{}
else
{
arr[row][col] ='*';
fill(arr,row+1, col);
fill(arr,row-1,col);
fill(arr,row,co l+1);
fill(arr,row,co l-1);
}
}
void disp(char arr[][50])
{
int i,j;
printf("\nThe filled shape is:\n");
for(i=0;i<50;i+ +)
{
for(j=0;j<50;j+ +)
{
printf("%c",arr[i][j]);
}
printf("\n");
}
}
Comment