Nov 23, 2020 at 7:32am
Hello i currently have a program that makes a downward star pyramid and based on the user input makes rows from it.
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 26
|
#include <iostream>
using namespace std;
int main()
{
int rows;
cout << "Enter number of rows: ";
cin >> rows;
for(int i = rows; i >= 1; --i)
{
for(int space = 0; space < rows-i; ++space)
cout << " ";
for(int j = i; j <= 2*i-1; ++j)
cout << "* ";
for(int j = 0; j < i-1; ++j)
cout << "* ";
cout << endl;
}
return 0;
}
|
so the output looks like this if i put 9 for example
1 2 3 4 5 6 7 8 9 10 11
|
* * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
|
The way i would wanted it to be like this
1 2 3 4 5 6 7
|
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
|
Last edited on Nov 23, 2020 at 7:45am
Nov 23, 2020 at 9:27am
also change your prompt. Your output is what would be expected from the prompt given.