Back to diamond problem

I want to keep the outside stars only and remove the inside diamond shape
to be like

          *
         * *
        *    *
       *       *
      *         *
       *       *
        *    *
         * *
          *
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
using namespace std;

int main() {
    int row;
    // top half
    for (row = 1; row <= 5; row++) {
        for (int space = 1; space <= 5 - row; ++space)
            cout << ' ';
        for (int star = 1; star <= 2 * row - 1; star++)
            cout << '*';
        cout << '\n';
    }
    // bottom half
    for (row = 4; row >= 1; row--) {
        for (int space = 1; space <= 5 - row; space++)
            cout << ' ';
        for (int star = 1; star <= 2 * row - 1; star++)
            cout << '*';
        cout << '\n';
    }
    cout << endl;
    return 0;
}


any help?



appreciate your helping
Last edited on
it's diamond in the compiler I don't know why it appear like this here.. I hope you get what I mean anyways

thanks
Use [output][/output] tags to preserve indentation.

So what exactly is the problem? What part of the code is not doing what you want?
Edited
The problem is I dont know how to make it like this
The code shows a fully starred diamond shape
I just want it to be a starred sided diamond (empty from inside)
So instead of printing asterisks everywhere, you'll only want to print 1 or 2 each row. You'll need to look at the parts of the loop that print the asterisks and edit them to only print the asterisks on the edges and print spaces in the center.
Tried.
Couldn't reach the answer.
Last edited on
Well, I don't intend to do it for you. Look at the loops on 10-11 and 18-19; you only want to print out the first and last asterisk and otherwise print spaces.
Thank you, Sir.
Topic archived. No new replies allowed.