백준 algorithm
백준 2439번 별 찍기 -2
nirocat
2020. 7. 8. 21:18
반응형
https://www.acmicpc.net/problem/2439
2439번: 별 찍기 - 2
첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제 하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오.
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> | |
#include <string> | |
using namespace std; | |
int main(void) | |
{ | |
int n = 0; | |
cin >> n; | |
for (int i=0;i<n;i++)//n번째 줄 | |
{ | |
for (int j = n - 1; j > i; j--) | |
{ | |
cout << " "; | |
} | |
for (int k = 0; k <= i; k++) | |
{ | |
cout << "*"; | |
} | |
cout << "\n"; | |
} | |
return 0; | |
} |
728x90