Notice
Recent Posts
Recent Comments
Link
250x250
«   2025/04   »
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
Archives
Today
Total
관리 메뉴

피너클의 it공부방

백준 2444 별 찍기 - 7 (c++) : 피너클 본문

백준

백준 2444 별 찍기 - 7 (c++) : 피너클

피너클 2022. 8. 29. 00:50
728x90
반응형

https://www.acmicpc.net/problem/2444

 

2444번: 별 찍기 - 7

첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.

www.acmicpc.net

구현문제다.

#include <iostream>

using namespace std;

int n;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = n-1; i >= 1; i--) {
		for (int j = 0; j < i; j++) cout << ' ';
		for (int j = 0; j < 2 * n - 1 - 2 * i; j++) cout << "*";
		cout << '\n';
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) cout << ' ';
		for (int j = 0; j < 2 * n - 1 - 2 * i; j++) cout << "*";
		cout << '\n';
	}
}

전체코드다.

728x90
반응형
Comments