흔한 for문 별찍기

#include <stdio.h>


#define MAX_DEPTH 20


int main(void)

{

int nRow=0, nBlank=0, nStar=0, nDepth=0;


do 

{

printf("Enter the depth of Triangle(1 ~ %d): ", MAX_DEPTH);

scanf("%d", &nDepth);

} while ((nDepth<=0) || (nDepth>MAX_DEPTH));



for(nRow=0; nRow<nDepth; nRow++) 

{

for(nBlank=0; nBlank<nDepth-nRow; nBlank++)

printf(" ");

for(nStar=0; nStar<(2*nRow+1); nStar++)

printf("*");


printf("\n");

}

return 0;

}