[시작] - 클래스는 메서드나 프로퍼티 등을 다른 클래스로부터 상속받을 수 있음 : 자식 클래스 : 어떤 클래스로부터 상속을 받은 클래스 : 부모 클래스 : 자식 클래스에게 자신의 특성을 물려준 클래스- 자식 클래스는 부모 클래스의 메서드, 프로퍼티, 서브스크립트를 사용할 수 있음- 자식 클래스는 부모 클래스로부터 물려받은 것들을 재정의할 수 있음- 기반 클래스 : 다른 클래스로부터 상속을 받지 않은 클래스 [클래스 상속] 123class 클래스이름: 부모클래스이름{ 프로퍼티와 메서드들}cs 코드 재사용 용이, 기능 확장 시 기존 클래스를 변경하지 않고도 새로운 기능을 추가한 클래스를 정의할 수 있음 [재정의] - 자식 클래스는 부모 클래스로부터 물려받은 특성 (인스턴스 메서드, 타입 메서드, 인스턴스 ..
[시작] - 클래스, 구조체, 열거형에는 컬렉션, 리스트, 시퀀스 등 타입의 요소에 접근하는 단축 문법인 서브스크립트를 정의할 수 있음 - 별도의 설정자, 접근자를 정의하지 않아도 인덱스를 통해 값을 설정하거나 가져올 수 있음- 배열, 딕셔너리에서 array[index], dictionary[key]와 같이 표현하는 것 - 한 타입에 여러 개의 서브스크립트 정의 가능- 다른 타입을 인덱스로 갖는 여러 개의 서브스크립트 중복 정의 가능 [서브스크립트 문법] - 인스턴스의 이름 뒤에 대괄호로 감싼 값을 써줌으로써 인스턴스 내부의 특정 값에 접근할 수 있음 - subscript 키워드를 사용하여 정의 : 매개변수의 개수, 타입, 반환 타입 등을 지정 : 읽기전용 / 읽기쓰기 전용으로 구현 가능- 타입의 구현부..
12345678910111213141516171819202122232425262728293031323334353637let input = (readLine()?.split(separator: " ").map { Int($0)! })!let row = input.first!let column = input.last!var array = [[String]]()for _ in 0.. String in String(string) }) array.append(a)}var ninesAll = 0var nines = [Int]()for i in array{ var temp = 0 for subArray in i{ for char in subArray{ if(char == "9"){ temp += 1 } } } nin..
1234567891011121314151617181920212223242526272829303132333435363738let queryCount = Int((readLine()?.split(separator: " ").last!.description)!)!var sequence = (readLine()?.split(separator: " ").map({ (content) -> Int in Int(content)!}))!var inputs = [[Int]]()for _ in 0..
12345678910111213141516171819202122232425262728let input = Int(readLine()!)!var inputs = [String]()for _ in 1...input{ inputs.append(readLine()!)}for input in inputs{ var stack = [Character]() for i in input{ if(i == "("){ stack.append("(") } else { if let paren = stack.last { if(paren == "("){ stack.removeLast() } else { stack.append(")") } } else { stack.append(")") } } } if(stack.isEmpty){ pr..
123456789101112131415161718192021222324252627282930313233343536373839import Foundation let input = Int(readLine()!)!var stack = [Int]()var commands = [String]()for _ in 1...input{ commands.append(readLine()!)}for command in commands{ if(command.contains("push")){ let number = Int((command.split(separator: " ").last?.description)!)! stack.append(number) } else { switch(command){ case "pop": if le..
1234567891011121314151617181920212223242526272829let input = readLine()!var array = [Int]()var cards = [0,0,0,0,0,0,0,0,0,0]for i in input{ array.append(Int(i.description)!)}for number in array{ cards[number] += 1}var cardsExceptSixAndNine = [Int]()for i in 0..= six+nine){ print(max)} else{ let sub = six+nine-max*2 let more = Int((Double(sub) / 2.0).rounded()) print(max + more)} Colored by Color..