I need help in making a hollow parallelogram
I want this;
1 2 3 4
|
**********
* *
* *
**********
|
So far, I got this;
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 27 28
|
#include <iostream>
using namespace std;
int main()
{
int lines = 0 , row = 0;
cin >> lines;
for(int top_border=0 ; top_border<lines*3 ; top_border++)
{
cout << "*";
}
cout << endl;
for(int side_border=0 ; side_border<lines-1 ; side_border++)
{
cout << "*";
for(int hollow=0 ; hollow<lines*3-2 ; hollow++)
{
cout << " ";
}
cout << "*" << endl;
}
for(int low_border=0 ; low_border<lines*3 ; low_border++)
{
cout << "*";
}
}
|
How can I add space space before the left border?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
int main()
{
int lines = 0;
cin >> lines;
for(int row=1 ; row<=lines ; row++)
{
for(int space=0 ; space<lines-row; space++)
{
cout << " ";
}
for(int star=0 ; star<lines*3 ; star++)
{
cout << "*";
}
cout << endl;
}
}
|
Is there any way i can utilize this code for the space before the left border?
Last edited on
Topic archived. No new replies allowed.