### Hollow Diamond Shape

I want to create a hollow shaped diamond, I've actually already figured it out, but the shape will get messy if i change either one of the variable's value
here's my code:

 ```#include using namespace std; int main() { int space = 4, row, i, j; for ( row = 1; row <= 7; row++ ) { if ( row > 4 ) { for ( i = 2; i <= space; i++ ) { if ( i == row - 2) cout << '*'; else cout << ' '; } for ( i = space; i >= 1; i-- ) { if ( i == row - 3) cout << '*'; else cout << ' '; } cout << endl; } else { for ( i = space; i >= 1; i-- ) { if ( i == row ) cout << '*'; else cout << ' '; } for ( i = 2; i <= space; i++ ) { if ( i == row ) cout << '*'; else cout << ' '; } cout << endl; } } system("pause"); return 0; } ```

i tried to fix this but didn't found the solution :(
could someone tell me what have i done wrong?

oh and i have another request,
I have a normal diamond shape code, and if possible, i'd like to base the hollowed shape from this code:

 ```#include using namespace std; int main() { int space = 7, row = 7, stars = 1, i, j; for ( int init = 1; init <= row; init++ ) { for (i = 1; i <= space; i++) cout << ' '; for (j = 1; j <= stars; j++) cout << '*'; if ( init > (row-1)/2 ) { space++; stars -= 2; } else { space--; stars += 2; } cout << endl; } cout << endl; system("pause"); return 0; } ```

any help is appreciated, thanks :)
Last edited on
you could do something like this

bbxbb
bxbxb
xbbbx
bxbxb
bbxbb

and then parse out the b with `char b = ' ' `
Topic archived. No new replies allowed.