문제 링크입니다: www.acmicpc.net/problem/2439
2439번: 별 찍기 - 2
첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제 하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오.
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains 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 << " "; | |
} | |
for (int j = i; j < N; j++) | |
{ | |
cout << "*"; | |
} | |
cout << "\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 2441번 별 찍기 - 4 (0) | 2021.04.14 |
---|---|
백준 2440번 별 찍기 - 3 (0) | 2021.04.14 |
백준 2438번 별 찍기 - 1 (0) | 2021.04.14 |
백준 2061번 좋은 암호 (0) | 2021.04.11 |
백준 2052번 지수연산 (0) | 2021.04.09 |