I need a simple algorithm with nothing complicated, no pointers, arrays ect.
I need to draw a HOLLOW rectangle of any given dimensions..
NOT
****
****
****
No "*" inside, only the borders.
Please somebody tell me the right way to do it.
I need a simple algorithm with nothing complicated, no pointers, arrays ect.
I need to draw a HOLLOW rectangle of any given dimensions..
NOT
****
****
****
No "*" inside, only the borders.
Please somebody tell me the right way to do it.
how about this?
printf(***);
printf(* *);
printf(***);
Try with loops...............I'd recomend for
I need an algorithm
The users enters the dimesnion, say:
height = 3
width = 4
output:
****
*``*
****
but ofcourse the ` arent there. only put it in so that the output would look right.
Does anbody know an algorithm for a hollow rectangle
thanks
are you the same person who asked this in the game board..
Code:do { cin>>ans; ans=toupper(ans); } while(ans!='Y' && ans!='N'); if(ans=='Y') { dont_cross_post(); gameprog_board(); } else gameprog_board();
-
The horizontal will be your inner loop and the vertical will be your outer loop. The number of blanks will be two less than each dimension. Play with it a bit. We don't want to do all of your homework.
OK, I'll bite this once but I'm a total noob myself and can't testify to the quality of my solution. It works, but it's not pretty.
-That1Guy
Code:#include <stdio.h> int main(void) { int i; int j; int numRows = 15; int numCols = 15; int rowCount = 0; int colCount = 0; for(i = 0; i < numRows; i++) { if(rowCount == 0 || rowCount == (numRows - 1)) { rowCount++; for(j = 0; j < numCols; j++) printf("*"); printf("\n"); } else { rowCount++; for(j = 0; j < numCols; j++) { if(colCount == 0 || colCount == (numCols - 1)) { colCount++; printf("*"); } else { colCount++; printf(" "); } } printf("\n"); colCount = 0; } } return(0); }
This question is asked often enough that a board search will work wonders. I know that quzah and I gave solutions to this problem not a week ago.
-Prelude
My best code is written with the delete key.