(note: had to put dashes for the diamond to actually look like a diamond. Not actually part of the program)
I have 2 questions that I can not figure out. How to properly space the star from the left so like the single star on top is 5 spaces, the next is 4, then 3, 2,1 ect.
The next question is How to get the stars to descend after that middle row.
heres what I have so far. The loops are split up from Top of diamond, middle, and bottom
// PART 2: print top of diamond lines
for (int i = 0; i < row; i++)
{
for (int j = 0; j < i; j++)
{
cout << "*";
}
cout << endl;
}
// PART 3: print center line
for (int i = 0; i < row; i++)
{
cout << "*";
}
cout << endl;
// PART 4: print bottom of loop lines
for (int i = 0; i > row; i++)
{
for (int j = row; j < i; j--)
{
cout << "*";
}
cout << endl;
}
Question 1: You can use the manipulator setw() form the <iomanip> library. Setw is used to output the vaule of an expression in a specific number of columns. <iomanip> library offers you a lot of functions to format the output, it not hard, you should read it to make your desired output.
Question 2: You just reverse the process, not necessary to print center line. Set for ( i=(N-i); i>=1; i--);
Furthermore, your code is wrong, in ur Part 2, the result will be increasing by 1 * in each line, not meet the require of task( Line 1: 1 *, line 2: 3 *, line 3: 5 *, each line the number of starts will increase 2 not 1 ).