[정올] Language Coder_반복제어문3_형성평가4_code143 (C)
두비니
·2020. 4. 8. 00:42
C언어
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
for (int i = n; i >= 1; i--) {
for (int j = 0; j < n - i; j++) {
printf(" ");
}
for (int j = 0; j < i; j++) {
printf("*");
}
for (int j = 0; j < i - 1; j++) {
printf("*");
}
printf("\n");
}
for (int i = 2; i <= n; i++) {
for (int j = 0; j < n - i; j++) {
printf(" ");
}
for (int j = 0; j < i; j++) {
printf("*");
}
for (int j = 0; j < i - 1; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
Python
n = int(input())
for i in range(n, 0, -1):
print(" "*(n-i), end="")
print("*"*i, end="")
print("*"*(i-1))
for i in range(2, n+1):
print(" "*(n-i), end="")
print("*"*i, end="")
print("*"*(i-1))
'Coding_Algorithm > 정올 문제풀이' 카테고리의 다른 글
[정올] Language Coder_반복제어문3_형성평가7_code146 (C) (0) | 2020.04.09 |
---|---|
[정올] Language Coder_반복제어문3_형성평가5_code144 (C) (0) | 2020.04.08 |
[정올] Language Coder_반복제어문3_자가진단7_code554 (C) (0) | 2020.04.07 |
[정올] Language Coder_반복제어문3_자가진단6_code553 (C) (0) | 2020.04.06 |
[정올] Language Coder_반복제어문3_자가진단5_code552 (C) (0) | 2020.04.05 |