My issue
The code is executed successfully but can’t submit it
My code
#include <bits/stdc++.h>
using namespace std;
#include<iostream>
int main() {
// your code goes here
int n;
std::cin >> n;
// Upper triangle
for (int i = 1; i <= n; i++) {
// Print spaces
for (int j = i; j < n; j++) {
cout << " ";
}
// Print stars
for (int j = 1; j <= (2 * i - 1); j++) {
cout << "*";
}
cout << endl;
}
// Lower triangle
for (int i = n - 1; i >= 1; i--) {
// Print spaces
for (int j = n; j > i; j--) {
cout << " ";
}
// Print stars
for (int j = 1; j <= (2 * i - 1); j++) {
cout << "*";
}
cout << endl;
}
}
Problem Link: STAR Pattern Practice Coding Problem