-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2447번.swift
36 lines (32 loc) · 932 Bytes
/
2447번.swift
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
31
32
33
34
35
36
// 출처 : 백준 별찍기 - 10
// https://www.acmicpc.net/problem/2447
// 풀이 : hogumachu
import Foundation
let input = Int(readLine()!)!
var star: [[Character]] = Array(repeating: Array(repeating: "*", count: input), count: input)
func deleteStar(_ x: Int, _ y: Int, _ num: Int) -> Void {
if num < 3 {
return
}
for i in x-2*(num/3)..<x-(num/3) {
for j in y-2*(num/3)..<y-(num/3) {
star[i][j] = " "
}
}
deleteStar(x-(2*num/3), y-(2*num/3), num/3)
deleteStar(x-(2*num/3), y-(num/3), num/3)
deleteStar(x-(2*num/3), y, num/3)
deleteStar(x-(num/3), y-(2*num/3), num/3)
deleteStar(x-(num/3), y, num/3)
deleteStar(x, y-(2*num/3), num/3)
deleteStar(x, y-(num/3), num/3)
deleteStar(x, y, num/3)
}
deleteStar(input, input, input)
for i in 0..<input {
var str = ""
for j in 0..<input {
str += "\(star[i][j])"
}
print(str)
}