Hollow rectangle shape

Hey all so I got my code written for a hollow rectangle but its not exactly giving me the correct width and height I input. Any ideas?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
for(int a=0; a<Height; a++)
	{
		 for(int b=0; b<Width; b++)
		 {
			 if(a==0 || a==Height-1 || b==0 || b==Width-1)
			 {
			 cout << "*";
			 }
			 else
			 {
			  cout << " ";
			 }
		 }
  cout<<endl;
	}
Works fine. What do you have problem with?
Make a function that draws a rectangle

1
2
3
4
5
6
7
8
9
10
void drawrect (int height, int length)
{
   ///lmake a loop that draws just a line of '*' =width

  ///make a loop that draws one '*' at start and at end of the width in the range (height==2 upto height-1)

  /// repeate loop one
 }

/// would be easier to debug 
Last edited on
Registered users can post here. Sign in or register to post.