#include <iostream>
using namespace std;

class Star {
private:
    int n;
public:
    Star(int num) : n(num) {}

    void printStar() {
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < n - i; j++) cout << " ";
            for (int k = 0; k < 2 * i - 1; k++) cout << "*";
            cout << endl;
        }
    }
};

int main() {
    int n;
    cin >> n;
    Star s(n);
    s.printStar();
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: