MUKER_DEV with iOS

[swift] 백준 - 2444번: 별 찍기 - 7 본문

🤖 알고리즘/BAEKJOON

[swift] 백준 - 2444번: 별 찍기 - 7

MUKER 2023. 4. 16. 22:40
 

2444번: 별 찍기 - 7

첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.

www.acmicpc.net


성공 풀이

let N = Int(readLine()!)!
for i in 1...N{ print(String(repeating: " ", count: N-i)+String(repeating: "*", count: 2*i-1)) }
for i in 1..<N{ print(String(repeating: " ", count: i)+String(repeating: "*", count: 2*(N-i)-1)) }