Test

문제 풀이Stack 개념과 동일하다.스택(Stack)은 마지막으로 입력 데이터가 먼저 출력되는 방식이다.(LIFO : Last in First out)func stack() -> Bool { let word = readLine()! var stack: [Character] = [] word.forEach { if !stack.isEmpty && stack.last! == $0 { // 마지막 데이터 제거 stack.removeLast() } // 데이터 추가 stack.append($0) } return Set(stack).count == stack.count}let n = Int(readLi..

정답let n = Int(readLine()!)!for i in 1...n { let star = String(repeating: " ", count: n - i) + String(repeating: "*", count: 2 * i - 1) print(star)}for i in 1.. String(repeating:count:)를 이용해서 풀이 init(repeating:count:) | Apple Developer DocumentationCreates a new string representing the given string repeated the specified number of times.developer.apple.com출처 만도스의 개발 일기장 dev-mandos.tistory.com

https://www.acmicpc.net/problem/10810 let input = readLine()!.split(separator: " ").map { Int($0)! }let n = input[0], m = input[1]var basket = [Int](repeating: 0, count: n + 1)for _ in 0.. 출처 [BOJ] 백준 10810 공 넣기 (Swift)문제 https://www.acmicpc.net/problem/10810 10810번: 공 넣기 도현이는 바구니를 총 N개 가지고 있고, 각각의 바구니에는 1번부터 N번까지 번호가 매겨져 있다. 또, 1번부터 N번까지 번호가 적혀있는 공을 매dev-mandos.tistory.com

https://www.acmicpc.net/problem/11654import Foundationlet chars = readLine()!.map{$0}for ch in chars { print(ch.asciiValue!)} asciiValue | Apple Developer DocumentationThe ASCII encoding value of this character, if it is an ASCII character.developer.apple.com


백준에서 코테를 준비하는데 값을 가져올 때 readLine() 함수를 많이 사용해서 readLine에 관하여 포스팅하려 한다.readLine()Returns a string read from standard input through the end of the current line or until EOF is reached.→ 현재 줄의 끝 또는 EOF(End Of File)에 도달할 때까지 표준 입력에서 읽은 문자열을 반환합니다. XCode에서 사용 방법1) 프로젝트 생성 - macOS [Command Line Tool]로 생성 단일 문자열 받아오기import Foundationlet a = readLine()!print(a) 결과는 처음 커서에 원하는 값을 입력하면 출력할 수 있다. 여러 문자열 받아..

문제https://www.acmicpc.net/problem/10951while let input = readLine()?.split(separator: " ").map({ Int($0)! }) { let a = input[0], b = input[1] print(a + b)} 출처 [BOJ] 백준 10951 A+B - 4 (Swift)문제 https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 풀이 Swift에서 cmd + D 를 입력해서 EOF를 입력시킬 수 있음 EOF가dev-mandos.tistory.com