Quick actions

cmd+k|ctrl+k

Navigation

Languages

Hourglass pyramid.cpp

Snippet info

Language

Cpp

Visibility

public

Author

kodlikejamesz

Created

2024-04-03T07:30:43.405355Z

Updated

2024-04-03T07:52:00.840444Z

#include <iostream>
using namespace std;


int main()
{
for (int row = 2; row > 0; row--)
{
for (int col = 0; col < 3 - row; col++)
{
cout << " ";
}
cout << "*";
for (int col = 0; col < row * 2 - 1; col++)
{
cout << " ";
}

cout << "*";
cout << endl;

}
cout << " " << " " << " " << "*";
cout << endl;
for (int row = 0; row < 2; row++)
{
for (int col = 0; col < 2 - row; col++)
{
cout << " " ;
}
cout << "*";
for (int col = 0; col < row * 2 + 1; col++)
{
cout << " ";
}
cout << "*";
cout << endl;

}

return 0;
}
INFO