* ** *** **** *** ** *
#include <stdio.h> #include <conio.h> int main(void) { int a,b,c; int d,e,f ; a=1, c=1, d=0; scanf("%d", &b); e=b, f=1; while (a<b) { c=1, d=0; printf("\n"); while (d<f) { printf("*"); c++, d++; } f++, a++; } a=0, c=1, d=0; while (a<e) { c=1, d=0; printf("\n"); while (d<b) { printf("*"); c++, d++; } a++, b--; } _getch(); return 0; }
#include <stdio.h> #include<stdio.h> int main() { int a, b, c; scanf("%d",&c); for(a=1;a<2*c;a++){ if(a<=c){ for(b=1;b<=a;b++) printf("*"); printf("\n"); } else { for(b=2*c-a;b>=1;b--) printf("*"); printf("\n"); } } return 0; }
3 (<- scanf로 입력) * *** *****
#include <stdio.h> int main(void) { int n, a, b, c; a=1, b=0, c=0; scanf("%d", &n); while (a<=n) { printf("\n"); while(c<n) { printf(" "); c++;} b=0; while(b<2*a-1){ printf("*"); b++;} c=a; a++; } getch(); return 0; }
#include <stdio.h> #include<stdio.h> int main(){ int a, b, n; scanf("%d",&n); for(a=1;a<=n;a++){ for(b=n;b>a;b--) printf(" "); for(b=1;b<=2*a-1;b++) printf("*"); printf("\n"); } return 0; }
3 (<- scanf로 입력) * *** ***** *** *
#include <stdio.h> int main(void) { int n, a, b, c, d; a=1, b=0, c=0; scanf("%d", &n); while (a<=n-1) { printf("\n"); while(c<n) { printf(" "); c++; } b=0; while(b<2*a-1){ printf("*"); b++; } c=a, a++; } a=1, b=0, c=0; d=n; while (a<=n) { printf("\n"); while(c<a) { printf(" "); c++; } while(b<2*d-1){ printf("*"); b++; } c=0, d--, a++, b=0; } getch(); return 0; }
#include<stdio.h> int main(){ int a, b, n; scanf("%d",&n); for(a=1;a<=2*n-1;a++){ if(a<=n){ for(b=n;b>a;b--) printf(" "); for(b=1;b<=2*a-1;b++) printf("*"); printf("\n"); } else{ for(b=1;b<=a-n;b++) printf(" "); for(b=1;b<=4*n-2*a-1;b++) printf("*"); printf("\n"); } } return 0; }