swift 썸네일형 리스트형 [swift] 1차원 배열 만들기 import UIKit var arr1 = [Int]()var arr2: [Int] = [0,0,0]var arr2_1 = [0,0,0] // 앞에 타입 생략 가능var arr3: [Int] = [Int](count: 3, repeatedValue: 0)var arr4: Array = Array()var arr4_1 = Array() // 앞에 타입 생략 가능 println("arr1 = \(arr1)")println("arr2 = ")for i in arr2 { print("\(i) ")}println()println("arr2_1 = \(arr2_1)")println("arr3 = \(arr3)")println("arr4 = \(arr4)") println("arr4_1 = \(arr4_1)") 더보기 [swift] 달팽이 // Playground - noun: a place where people can play import UIKit let n = 5 var map: [[Int]] = [[Int]](count: n, repeatedValue: [Int](count: n, repeatedValue: 0))var number = 1var lineCount = nvar xy: (x:Int, y:Int) = (-1, 0) while true { for i in 0.. 더보기 [swift] 비어있는 2차원 배열 만들기 import UIKit var str = "Hello, playground" let n = 5var emptyArray = [String]()var emptyArray2: [[Int]] = [[Int]](count: n, repeatedValue: [Int](count: n, repeatedValue: 0)) emptyArray2[0][0] = 1 for first in emptyArray2 { for value in first { print("\(value) ") } println()} println("END") 더보기 이전 1 다음