문제 링크입니다: www.acmicpc.net/problem/2446
2446번: 별 찍기 - 9
첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int N; | |
cin >> N; | |
for (int i = N; i >= 1; i--) | |
{ | |
for (int j = 0; j < N - i; j++) | |
{ | |
cout << " "; | |
} | |
for (int j = 0; j < 2 * i - 1; j++) | |
{ | |
cout << "*"; | |
} | |
cout << "\n"; | |
} | |
for (int i = 2; i <= N; i++) | |
{ | |
for (int j = 0; j < N - i; j++) | |
{ | |
cout << " "; | |
} | |
for (int j = 0; j < 2 * i - 1; j++) | |
{ | |
cout << "*"; | |
} | |
cout << "\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
[KOI 초등부] 백준 2455번 지능형 기차 (0) | 2021.04.18 |
---|---|
백준 13718번 Tavan (2) | 2021.04.17 |
백준 2445번 별 찍기 - 8 (0) | 2021.04.15 |
백준 2444번 별 찍기 - 7 (0) | 2021.04.15 |
백준 2443번 별 찍기 - 6 (0) | 2021.04.15 |