문제 링크입니다: www.acmicpc.net/problem/2442
2442번: 별 찍기 - 5
첫째 줄에는 별 1개, 둘째 줄에는 별 3개, ..., N번째 줄에는 별 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 - 1; i >= 0; i--) | |
{ | |
for (int j = 0; j < i; j++) | |
{ | |
cout << " "; | |
} | |
int starCnt = 2 * (N - i) - 1; | |
for (int j = 0; j < starCnt; j++) | |
{ | |
cout << "*"; | |
} | |
cout << "\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 2444번 별 찍기 - 7 (0) | 2021.04.15 |
---|---|
백준 2443번 별 찍기 - 6 (0) | 2021.04.15 |
백준 2441번 별 찍기 - 4 (0) | 2021.04.14 |
백준 2440번 별 찍기 - 3 (0) | 2021.04.14 |
백준 2439번 별 찍기 - 2 (0) | 2021.04.14 |