### Making these horizontal lines vertical

Hey all! Been racking my brain working on getting the horizontal lines within the diamond trying to make them vertical.

I'm guessing that I need to take the if-else pair (line 32) outside of the brackets and perhaps upwards beneath the initial for loop (line 19) but anything i try results in disaster!

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647`` ``````#include using namespace std; int main() { int n; int j; char border; char fill; cout << "Enter Diamond radius: "; cin >> n; cout << "Enter border character: "; cin >> border; cout << "Enter a fill character: "; cin >> fill; for (int i = (1-n); i < n; i++) { for (j = 0; j < abs(i); j++) { //outer spaces cout << " "; } cout << border; if(abs(i) != (n-1)) //if not the first or last row, print a second "A" { for (int k = 1; k < 2*((n-1)-abs(i)); k++) { //inner spaces if (j % 2 == 0) //if on an even row output spaces { cout << " "; } else //if on an odd row output the fill character { cout << fill; } } cout << border; } cout << endl; } }``````

Thanks guys!
I think you need to include this line...
`# include <cmath> `
To get them vertical?

All works fine without it. Why is it necessary?
On line 32 replace j with (k+i)
 ``1234567891011121314151617181920`` `````` x xdx x d x xd d dx x d d d x xd d d d dx x d d d d d x xd d d d d d dx x d d d d d d d x xd d d d d d d d dx x d d d d d d d x xd d d d d d dx x d d d d d x xd d d d dx x d d d x xd d dx x d x xdx x ``````
I cant believe it was so simple! Thankyou so much!
Topic archived. No new replies allowed.