#include <stdio.h>

int main() {
    int n,star;
    scanf("%d",&n);
    //공백
    for(int i=0; i<n;i++) {
        for(int j=0; j<n-1-i; j++) {
            printf(" ");
        }
        //star 이 1 이면 별 출력
        star=1;
        for (int j=0; j<2*(i+1)-1; j++) {
            if(star)  {
                printf("*");
                star=0;
            }
            else {
                printf(" ");
                star=1;
                    }
        
        }
        printf("\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: