#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int cnt=0;
int a;
int b=0;

void star(int n){
    a=n-1-b;
    if(n==0) return;

    if(cnt<n-a){
        printf("*");
        cnt++;
        star(n);
    }else{
        printf("\n");
        cnt=0;
        b++;
        star(n-1);
    }
}

int main() {
    int n;
    scanf("%d", &n);
    star(n);
    return 0;
}

Embed on website

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