BlazeB's Avatar
Light Poster
ok...this is really buggin me...the website automatically takes out the spaces
im gonna put 0's where the spaces shud b
HERE YA GO (better work)
input =
*****
*000*
*000*
*000*
*****
then output:
*****
*****
*****
*****
*****


must b able to work on Rectangle:
********
*0000000*
*0000000*
*0000000*
********

Ellipse:
000*****
0**00000**
*000000000*
*000000000*
*000000000*
*000000000*
*000000000*
0**00000**
000*****


The letter H:
***0000***
*0*0000*0*
*0*0000*0*
*0******0*
*000000000*
*0******0*
*0*00000*0*
*0*00000*0*
***00000***

BETTER WORK OR I GIVE UP
Thanks
-Blaze
BlazeB's Avatar
Light Poster
to make it look better just take out the 0's and put spaces in... Remember only the asterisks are the boundaries
Thanks
-Blaze
BlazeB's Avatar
Light Poster
please reply soon i need this program ASAP
thnx for all your help
-blaze
alok's Avatar
Ambitious contributor
Have tried your self yet Mr Blaze.
just try and then post your Source COde here,then we can help.
NO body going to write full source Code for you HERE!!
BlazeB's Avatar
Light Poster
heres what i have so far...i think this is the right logic but sum numbers are screwy or sumthing


/* fill.c is a program that takes an input of a boundary and
* the coordinates of an interior point. The program then takes
* those and dispays the boundary but as a closed shape. It
* fills the shape.
*/

#include "stdafx.h"
#include "simpio.h"
#include "strlib.h"

void fill(int Row, int Column, char Shape[21][21]);
void GO(int Row, int Column, char Shape[21][21]);

main(int count, int Count , int Sentinel, char Temp, int Row, int Column, string check)
{
char Shape[21][21];
for(count = 0; count < 21; count++) {
for(Count = 0; Count < 21; Count++) {
Shape[count][Count] = ' ';
}
}
Sentinel = 0;
printf("Start Entering Your Shape One Character At A Time And Enter [0] when done \n");
printf("Only 20 Rows & Columns Max \n");
for(Count = 0; Sentinel != 1; count++) {
for(count = 0; Sentinel != 1; count++) {
Temp = getchar();
if(Temp == '0') {
Sentinel = 1;
}
Shape[Count][count] = Temp;
}
}
check = GetLine();
printf("\nNow Enter The Row of the inner coordinate \n");
Row = (GetInteger() - 1);
printf("Now Enter The Column of the inner coordinate \n");
Column = (GetInteger() - 1);
fill(0, 0, Shape);
printf("\n");
}

void fill(int Row, int Column, char Shape[21][21])
{
if(Shape[Row][Column] != ' ' && Shape[Row][Column] != '0') {
printf("*");
} else {
GO(Row, Column, Shape);
}
if(Column == 20 && Row < 20) {
printf("\n");
fill(Row + 1, 0, Shape);
}
else if(Row < 20 && Column < 20) {
fill(Row, Column + 1, Shape);
}
}

void GO(int Row, int Column, char Shape[21][21])
{
int check = 0;
for(int count = Row; count >= 0; count = count - 1) {
if(Shape[count][Column] != ' ' && Shape[count][Column] != '0') {
check = check + 1;
count = 0;
}
}
for(int count = Row; count <= 20; count++) {
if(Shape[count][Column] != ' ' && Shape[count][Column] != '0') {
check = check + 1;
count = 20;
}
}
for(int count = Column; count >= 0; count = count - 1) {
if(Shape[Row][count] != ' ' && Shape[Row][count] != '0') {
check = check + 1;
count = 0;
}
}
for(int count = Column; count <= 20; count++) {
if(Shape[Row][count] != ' ' && Shape[Row][count] != '0') {
check = check + 1;
count = 20;
}
}
if(check == 4) {
printf("*");
} else {
printf(" ");
}
}
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Instead of posting the complete code if you can lay us the problem are we can help or you can use http://www.globaldevelopers.net/ and some software developer will do it for you also.

Last edited by shabbir; 3Jan2005 at 10:03..
BlazeB's Avatar
Light Poster
the problem is, I can't get the program to function correctly but i dont know where the prob is...btw alok, the user that posted b4 u told me to post my source code. If you want to know what the prgm is supposed to do then read the first descriptions and look at my pictures (it's the fill.c prgm)
-Blaze
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Yes I have read that and also if you have read this thread I have helped the guy who has started. Seeing the program and running is a difficult task but if you can recognize the problem are you can use this forums or you can use our partner sites for the work also.
Levi's Avatar
Go4Expert Member
Hey,
I am taking a course through epgy. Write what you have of the program
so far, and I'll see how I can help. Sorry for not responding sooner.
Levi
Levi's Avatar
Go4Expert Member
Hey,
I'm going to post the code for the fill.c program. I'm assuming that you have not completed it right? Use the code as a helper, don't just copy and paste. See if you can understand what is going on in there, and if you don't write back and ask your questions.
Of course, the fill function is the heart of the program. The Square, Circle and H, functions just make it easier to use the program. I found it near impossible to make it easy to imput a shape, so I wrote those. It's nice to know that there is someone else out there taking a programming course with EPGY.
Levi



/*
* This program fills in a recursive way the area enclosed
* by a shape from a given interior point without exeeding
* the boundary of the shape.
*/



#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "strlib.h"
#include "conio.h"
#define height 15
#define width 12


string shape[height][width];
void getinput(string shape[height][width]);
void printshape(string shape[height][width]);
void fill(string shape[height][width],int x, int y);
void square(string shape[height][width]);
void circle(string shape[height][width]);
void H(string shape[height][width]);
void prntsquare(string shape[height][width]);
main()
{
int x, y,ans;
printf("This program fills in a recursive way the area enclosed\nby a shape from a given interior point without exeeding\nthe boundary of the shape.\n");
printf("\n\nDo you want to see a \n1)square\n2)circle\n3)the letter H\n4)input yourself?\n");
printf("Type the number to make your selection....for example,\nfor square,enter number 1\n");
ans=GetInteger();
switch(ans)
{
case 1: square(shape);break;
case 2: circle(shape);break;
case 3: H(shape);break;
case 4: getinput(shape);break;
}
printf("Enter a x start position that is not an astrick.");
x=GetInteger();
printf("Enter a y start position that is not an astrick.");
y=GetInteger();
printshape(shape);
fill(shape,x,y);
printshape(shape);
}
void H(string shape[height][width])
{
int u,i;
clrscr();
for(u=0;u<height;u++)
{
for(i=0;i<width;i++)
{
shape[u][i]=" ";
}
}
for(u=0;u<=11;u++)
{
shape[u][0]="*";
shape[u][9]="*";
}
for(i=0;i<=9;i++)
{
if((((((i==0||i==1||i==2||i==7||i==8||i==9))))))
{
shape[0][i]="*";
shape[11][i]="*";
}
else
{
shape[4][i]="*";
shape[6][i]="*";
}
}
shape[4][2]="*";
shape[4][7]="*";
shape[6][2]="*";
shape[6][7]="*";
for(u=1;u<4;u++)
{
shape[u][2]="*";
shape[u][7]="*";
}
for(u=7;u<11;u++)
{
shape[u][2]="*";
shape[u][7]="*";
}
}
void circle(string shape[height][width])
{
int n, n1;
for(n=0;n<height;n++)
{
for(n1=0;n1<width;n1++)
{
shape[n][n1]=" ";
}
}
for(n=3;n<(width-3);n++)
{
shape[0][n]="*";
shape[14][n]="*";
}
for(n1=3;n1<12;n1++)
{
shape[n1][0]="*";
shape[n1][11]="*";
}
shape[1][2]="*";
shape[1][9]="*";
shape[2][1]="*";
shape[2][10]="*";
shape[12][1]="*";
shape[12][10]="*";
shape[13][2]="*";
shape[13][9]="*";
}


void square(string shape[height][width])
{
clrscr();
prntsquare(shape);
printf("\n\nEnter a co-ordinate inside the square");
}

void prntsquare(string shape[height][width])
{
int a,b;
for(a=0;a<height;a++)
{
for(b=0;b<width;b++)
{
shape[a][b]=" ";
}
}


for(a=0;a<9;a++)
{
shape[0][a]="*";
shape[11][a]="*";
}
for(b=0;b<12;b++)
{
shape[b][0]="*";
shape[b][9]="*";
}

for (a=0;a<height;a++)
{
for(b=0;b<width;b++)
{
printf("%s",shape[a][b]);
}
printf("\n");
}
}

void getinput(string shape[height][width])
{
int col, row,var;
var=0;
clrscr();

for(row=0;row<height;row++)
{
for(col=0;col<width;col++)
{
shape[row][col]=" ";
}
}
printf("The maximum limits for the shape is %d from top to bottom,\nand %d from left to right.\n",height,width);
printf("Enter your shape from left to right, top to bottom.\n");
printf("Each time you enter a astrick, the shape will print,\nshowing you what you have inputed sofar.");
printf("Enter \"-1\", to signal that you are done inputing.");
for(row=0;row<height;row++)
{
for(col=0;col<width;col++)
{
shape[row][col]=GetLine();
printf("\n");
if(StringEqual(shape[row][col],""))shape[row][col]=" ";
if(StringEqual(shape[row][col],"-1"))
{
shape[row][col]=" ";
printshape(shape);
var=-1;
break;
}
printshape(shape);
}
if(var==-1)
{
break;
}
printf("New line.");
}
}


void printshape(string shape[height][width])
{
int r,c;
for (r=0;r<height;r++)
{
for(c=0;c<width;c++)
{
printf("%s",shape[r][c]);
}
printf("\n");
}
printf("\n");
}


void fill(string shape[height][width],int x,int y)
{
if(StringEqual(shape[x][y],"*")==FALSE)
{
shape[x][y]="*";
fill(shape,x+1,y);
fill(shape,x-1,y);
fill(shape,x,y+1);
fill(shape,x,y-1);
}
}