728x90 ๋ฐ์ํ ์ซ์ ์ญ์์ผ๋ก ๋ฐฐ์ด์ ๋ฃ๊ธฐ1 Edabit Very Easy Swift Generate a Countdown of Numbers in an Array Example countdown(5) โ [5, 4, 3, 2, 1, 0] countdown(1) โ [1, 0] countdown(0) โ [0] ์ซ์๋ฅผ ๋ฃ์ผ๋ฉด ์ซ์๋ถํฐ 0๊น์ง ๋ฐฐ์ด์์ ๋ฃ์ด์ ๋ณด์ฌ์ค ๊ทธ๋์ ์์๋ ์ซ์ -> 0 ์์ผ๋ก ๋ด ํ์ด for๋ฌธ์ ์ฌ์ฉํ์ฌ ์ซ์์์ 0๋ถํฐ ์ฐจ๋ก๋๋ก ๋นผ์ ๋ฃ์ด์ฃผ๋ฉด ๋๊ฒ ๋ค ์๊ฐ func countdown(_ start: Int) -> [Int] { var arr = [Int]() for i in 0...start{ arr.append(start-i) } return arr } ๋ ์ข์ ์ ๋ต ํต์ฌ ๋ reversed() ์์? func countdown(_ start: Int) -> [In.. 2020. 1. 19. ์ด์ 1 ๋ค์ 728x90 ๋ฐ์ํ