#include
using namespace std;
int main()
{
int height;
cin >> height;
int rows = height;
int cols = height*2 - 1;
for (int r = 1; r <= rows; r++) {
for (int c = 1; c <= cols; c++)
if (c <= cols/2 - (r) || c >= cols/2 + (r)) cout << " ";
else cout << "*";
cout << endl;
}
return 0;
}
the one to print a balanced triangle
No comments:
Post a Comment