for문 별찍기

#include <stdio.h>
int main() {
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++) {
for (j = 0; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int n, i, j;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
for (j = 0; j < n-i; j++) {
printf(" ");
}
for (j = 0; j < i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int n, i, j;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
for (j = n - 1; j >= i; j--) {
printf(" ");
}
for (j = 0; j < i*2-1; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int n, i, j;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
for (j = n; j >= i; j--) {
printf("*");
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int n, i, j;

scanf("%d", &n);

for (i = 1; i <= n; i++) {
for (j = n - 1; j >= i; j--) {
printf(" ");
}
for (j = 0; j < i * 2 - 1; j++) {
printf("*");
}
printf("\n");
}

for (i = n; i > 0; i--) {
for (j = 0; j <= n - i; j++) {
printf(" ");
}
for (j = (i - 1) * 2 - 1; j > 0; j--) {
printf("*");
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int n, i, j;

scanf("%d", &n);

for (i = n; i >= 0; i--) {
if (i != 0) {
for (j = 0; j < n - i; j++) {
printf(" ");
}
}
for (j = 0; j < i; j++) {
printf("*");
}
if (i != 0) {
printf("\n");
}
}

for (i = 2; i <= n; i++) {
for (j = 0; j < n - i; j++) {
printf(" ");
}
for (j = 0; j < i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
Total views

댓글

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×