[백준] 별 찍기 -9 2446

Soohyeon B·2022년 10월 17일
0

알고리즘 문제 풀이

목록 보기
19/70
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;

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

  for(int j = 0; j < n - 1; j++) cout << ' ';
  cout << "*\n";

  for(int i = 1; i <= n - 1; i++) {
    for(int j = 1; j <= n - i - 1; j++) cout << ' ';
    for(int j = 1; j <= 2 * i + 1; j++) cout << '*';
    cout << "\n";
  }
}
profile
하루하루 성장하는 BE 개발자

0개의 댓글