#include <iostream>
using namespace std;
int main()
{
int height;
cout << "Enter height: ";
cin >> height;
// length of the line to be filled with '*'
int z=1;
// Display all lines except the bottom one
for (int i=0; i<height-1; i++) {
// spaces before the border
for (int j=height-1; j>i; j--)
cout << " ";
// ... and border itself
cout << "#";
// On the first row (i==0), there is no filling
if(i!=0) {
//
for (int k=1; k<=z; k++)
cout << "*";
cout << "#";
z += 2;
}
cout << endl;
}
// The bottom line consists of '#' only
for (int i=0; i<=z+1; i++)
cout << "#";
cout << endl;
return 0;
}
Comments
Leave a comment