백준 알고리즘 10995번 : 별 찍기 - 20

Zoo Da·2021년 12월 25일
0

백준 알고리즘

목록 보기
311/337
post-thumbnail

링크

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

sol1) 구현

#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int int64_t
using namespace std;

void Sol(int n){
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      for(int j = 0; j < n << 1; j++){
        if(j % 2 != 0) cout << " ";
        else cout << "*";
      }
    }
    else{
      for(int j = 0; j < n << 1; j++){
        if(j % 2 == 0) cout << " ";
        else cout << "*";
      }
    }
    cout << "\n";
  }
}

int32_t main(){
  fastio; 
  int n; cin >> n;
  Sol(n);
}

크리스마스의 저녁이니 별을 찍어보았습니다
문제의 예시를 보고 규칙을 찾아서 별을 찍어주면 됩니다.

profile
메모장 겸 블로그

0개의 댓글