근본없는 코딩

[C++] 백준2444 별찍기-7 본문

✔ Online Judge

[C++] 백준2444 별찍기-7

근본없는 개발자 2023. 6. 29. 23:52

#include <iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n - i; j++) {
			cout << ' ';
		}
		for (int j = 1; j <= i * 2 - 1; j++) {
			cout << '*';
		}
		cout << '\n';
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			cout << ' ';
		}
		for (int j = 1; j <= (n-i) * 2 - 1; j++) {
			cout << '*';
		}
		cout << '\n';
	}

	return 0;
}