336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
별찍기 1: https://www.acmicpc.net/problem/2438
별찍기 2: https://www.acmicpc.net/problem/2439
별찍기 3: https://www.acmicpc.net/problem/2440
별찍기 4: https://www.acmicpc.net/problem/2441
별찍기 5: https://www.acmicpc.net/problem/2442
별찍기 6: https://www.acmicpc.net/problem/2444
별찍기 7: https://www.acmicpc.net/problem/2445
별찍기 8: https://www.acmicpc.net/problem/2446
별찍기 9: https://www.acmicpc.net/problem/2522
별찍기 10: https://www.acmicpc.net/problem/10991
별찍기 11: https://www.acmicpc.net/problem/10992
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | #include <stdio.h> void print2438(int n) { for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) printf("*"); printf("\n"); } } void print2439(int n) { for (int i = 1; i <= n; i++) { for (int j = n; j > i; j--) //space printf(" "); for (int j = 0; j < i; j++) //star printf("*"); printf("\n"); } } void print2440(int n) { for (int i = 0; i < n; i++) { for (int j = n-i; j > 0; j--) //star printf("*"); printf("\n"); } } void print2441(int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) //space printf(" "); for (int j = n - i; j > 0; j--) //star printf("*"); printf("\n"); } } void print2442(int n) { for (int i = 0; i < n; i++) { for (int j = n-1; j > i; j--) //space printf(" "); for (int j = (i+1)*2 -1; j > 0; j--) //star printf("*"); printf("\n"); } } void print2444(int n) { for (int i = 0; i < n; i++) { for (int j = n - 1; j > i; j--) //space printf(" "); for (int j = (i + 1) * 2 - 1; j > 0; j--) //star printf("*"); printf("\n"); } for (int i = 1; i < n; i++) { //bottom triangle for (int j = 0; j < i; j++) printf(" "); for (int j = (n - i) * 2 - 1; j > 0; j--) printf("*"); printf("\n"); } } void print2445(int n) { for (int i = 1; i < n; i++) { for (int j = 0; j < i; j++) //first star printf("*"); for (int j = (n - i) * 2; j > 0; j--) printf(" "); for (int j = 0; j < i; j++) //second star printf("*"); printf("\n"); } for (int i = 1; i <= n * 2; i++) //center star printf("*"); printf("\n"); for (int i = n-1; i > 0; i--) { for (int j = 0; j < i; j++) //first star printf("*"); for (int j = (n - i) * 2; j > 0; j--) printf(" "); for (int j = 0; j < i; j++) //second star printf("*"); printf("\n"); } } void print2446(int n) { for (int i = 1; i <= n; i++) { for (int j = 1; j < i; j++) printf(" "); for (int j = (n-i+1)*2-1; j > 0 ; j--) printf("*"); printf("\n"); } for (int i = 1; i < n ; i++) { for (int j = n-i-1; j > 0; j--) printf(" "); for (int j = (i+1)*2-1; j > 0; j--) //first star printf("*"); printf("\n"); } } void print2522(int n) { for (int i = 1; i <= n; i++) { for (int j = n-i; j > 0; j--) printf(" "); for (int j = 1; j <= i; j++) printf("*"); printf("\n"); } for (int i = n-1; i > 0; i--) { for (int j = n-i; j > 0; j--) printf(" "); for (int j = i; j > 0; j--) //first star printf("*"); printf("\n"); } } void print10991(int n) { for (int i = 1; i <= n; i++) { for (int j = n - i; j > 0; j--) printf(" "); for (int j = i*2-1; j > 0 ; j--) { if (j % 2) //odd number printf("*"); else printf(" "); } printf("\n"); } } void print10992(int n) { for (int i = 1; i <= n; i++) { for (int j = n - i; j > 0; j--) printf(" "); if (i == n) { for (int j = i * 2 - 1; j > 0; j--) printf("*"); } else { for (int j = i * 2 - 1; j > 0; j--) { if (j == i * 2 - 1 || j == 1) printf("*"); else printf(" "); } } printf("\n"); } } int main() { int n; scanf("%d", &n); print10992(n); } | cs |
'PS > 백준 문제풀이' 카테고리의 다른 글
[백준 10808] 알파벳 개수 문제 (0) | 2018.03.29 |
---|---|
[백준 1158] 조세퍼스 순열 문제 (0) | 2018.03.28 |
[백준 1406] 에디터 문제 (3) | 2018.03.28 |
[백준 10799] 쇠막대기 문제 (0) | 2018.03.28 |
[백준 9012] 괄호 문제 (0) | 2018.03.28 |