알고리즘
[백준 2445][Swift] 별 찍기 - 8
moving
2022. 4. 1. 17:29
728x90
코드
let input = Int(readLine()!)!
for i in 1...(2 * input - 1) {
var total: String = ""
if i <= input {
for j in 1...(2 * input) {
if j <= i {
total += "*"
} else if j <= input+input - i {
total += " "
} else {
total += "*"
}
}
} else {
for j in 1...(2 * input) {
if j <= input+input - i {
total += "*"
} else if j > i {
total += "*"
} else {
total += " "
}
}
}
print(total)
}
https://www.acmicpc.net/problem/2445