My issue
i can’t solve this problem
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
// Upper Half
for (int i = 0; i < N; i++) {
// Left stars
for (int j = 0; j < N - i; j++) {
cout << "*";
}
// Spaces in the middle
for (int j = 0; j < 2 * i; j++) {
cout << " ";
}
// Right stars
for (int j = 0; j < N - i; j++) {
cout << "*";
}
cout << endl;
}
// Lower Half
for (int i = 0; i < N; i++) {
// Left stars
for (int j = 0; j <= i; j++) {
cout << "*";
}
// Spaces in the middle
for (int j = 0; j < 2 * (N - i - 1); j++) {
cout << " ";
}
// Right stars
for (int j = 0; j <= i; j++) {
cout << "*";
}
cout << endl;
}
return 0;
}
Learning course: Learn Programming and Problem Solving using C++
Problem Link: https://www.codechef.com/learn/course/sit-cpp-fall/SITFALL64/problems/CPPFALL465