알고리즘
[백준 2442][Swift] 별 찍기 - 5
moving
2022. 4. 1. 16:40
728x90
코드
let input = Int(readLine()!)!
for i in 1...input {
var total: String = ""
for j in 1..<input + i {
if j <= input - i {
total += " "
} else {
total += "*"
}
}
print(total)
}
https://www.acmicpc.net/problem/2442
2442번: 별 찍기 - 5
첫째 줄에는 별 1개, 둘째 줄에는 별 3개, ..., N번째 줄에는 별 2×N-1개를 찍는 문제 별은 가운데를 기준으로 대칭이어야 한다.
www.acmicpc.net