diff --git a/coding_freshmen/C++/Hollow_diamond.cpp b/coding_freshmen/C++/Hollow_diamond.cpp new file mode 100644 index 0000000..08ccdd5 --- /dev/null +++ b/coding_freshmen/C++/Hollow_diamond.cpp @@ -0,0 +1,58 @@ +#include +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; +}