How to Print Hollow shapes

As the title says, what is the concept of printing out hollow shapes?
You need to be way more specific.
sorry about that, how would i print out a hollow diamond, rectangle, etc.
LOL....

I'm sorry is this what you mean?

this is a hollow square:

1
2
3
4
5
    cout << "***************" << endl;
    for(int i = 0; i < 6; i++){
        cout << "*              *" << endl;
    }
    cout << "***************" << endl;

Last edited on
Sorry for laughing at this post...It was just way to vague...Please refer to my previous post in regards to your question.
The concept of printing hollowed out shapes is to print only outline, filling inside of your shape with whitespace characters.
nice, yours was the first was that actually worked for me. what about a vertical diamond?
Vertical diamond like:
   *
  * *
  * *
 *   *
 *   *
*     *
 *   *
 *   *
  * *
  * *
   *

You might notice that on each line there is two things you need to know/calculate: amount of whitespaces before first star and amount of whitespaces between first and second star.
Also you need to handle first and last lines (where only on star present).

FOr starters fugure out how to get amount of whitespaces from diamond size and line number.
okay im getting the hang of this. i just need to know how i could put different shapes side by side. instead of one below the other?
That's going to be a bit more difficult. You are going to need to output the row for all the shapes.

So if you wanted 2 square for instance it would be something like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example program
#include <iostream>
#include <string>

int main()
{
    int width = 4;
    int height = 4;
    std::cout << std::string(width, '*') + std::string(width, '*') << '\n';
    for(int i = 0; i < height - 2; ++i)
    {
        std::string row = std::string(width, ' ');
        row[0] = '*';
        row[width-1] = '*';
        std::cout << row + row << '\n';
    }
    std::cout << std::string(width, '*') + std::string(width, '*') << std::endl;
}
********
*  **  *
*  **  *
********
ok thanks everyone , i ended up finishing it
Topic archived. No new replies allowed.