Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions coding_freshmen/C++/Hollow_diamond.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;

for (int row = 0; row < n; row++)
{
// for space
for (int col = 0; col < n - row - 1; col++)
{
cout << " ";
}

// for stars print
for (int col = 0; col < 2 * row + 1; col++)
{
if (col == 0 || col == 2 * row)
{
cout << "*";
}
else
{
cout << " ";
}
}

cout << endl;
}

for (int row = 0; row < n; row++)
{
// for space
for (int col = 0; col < row; col++)
{
cout << " ";
}

// for stars print
for (int col = 0; col < 2 * n - 2 * row - 1; col++)
{
if (col == 0 || col == 2 * n - 2 * row - 2)
{
cout << "*";
}
else
{
cout << " ";
}
}

cout << endl;
}

return 0;
}