Skip to content

Instantly share code, notes, and snippets.

@myungseokang
Last active March 26, 2018 02:25
Show Gist options
  • Save myungseokang/bf0e6920760ac8b466cfbac97680a729 to your computer and use it in GitHub Desktop.
Save myungseokang/bf0e6920760ac8b466cfbac97680a729 to your computer and use it in GitHub Desktop.
Star of David
#include <stdio.h>
void main() {
int i, j, k, num;
scanf("%d", &num);
for(i=0; i<num; i++) {
for(j=0; j<num*2+1; j++) printf(" ");
for(k=i; k<num; k++) printf(" ");
for(j=0; j<=i; j++) printf("*");
for(j=0; j<i; j++) printf("*");
printf("\n");
}
for(i=num-1; i>0; i--) {
for(j=0; j<2; j++) printf(" ");
for(k=i; k<num; k++) printf(" ");
for(j=0; j<=i+num*2-1; j++) printf("*");
for(j=0; j<i+num*2-1; j++) printf("*");
printf("\n");
}
for(i=0; i<num; i++) {
for(j=0; j<=2; j++) printf(" ");
for(k=i; k<num-1; k++) printf(" ");
for(j=0; j<=i+num*2-1; j++) printf("*");
for(j=0; j<i+num*2-1; j++) printf("*");
printf("\n");
}
for(i=num; i>0; i--) {
for(j=0; j<=num*2+1; j++) printf(" ");
for(k=i; k<num; k++) printf(" ");
for(j=0; j<i-1; j++) printf("*");
for(j=0; j<i; j++) printf("*");
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment