Thank you for formatting your code. When you post an example, please also paste the stuff above main, otherwise we have to manually add it ourselves to get your code to compile.
if (characters.max_size())
if (characters.at(0) || characters.max_size())
What are you expecting this to be checking for? characters.at(0) simply returns the first character of your string. characters.max_size() is some super huge number that you shouldn't need to worry about. Both of those are then evaluated in a boolean statement. i.e. it doesn't make much sense.
Any non-zero expression in an if-statement always evaluates to true.
What exactly do you want the output to be?
e.g. if I input "12345", what should the output be?
Currently it's
12345
12345
12345
12345
12345 |
Did you want it to be
?
If so, look at the pattern: The first line is always the full string. The last line is always the full string. The middle part happens ([num rows] - 2) times, and the first characters, then [num rows - 2] spaces, then the last character. Think about that pattern as you formulate your if statements.
Or, did you want something more creative, like:
If it's the latter, then there's still a pattern to code to, it's just a bit trickier. The first string is normal. The last string is reversed. For the outer characters in the middle strings, notice that the index for the left character goes up by 1 each time, and the index for the right character does down by 1 each time.
It will probably be easier for you to just use a normal indexed for loop for this. Use the current index to help decide which character index to print.