전체보기
-
[백준 11022][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력 -8알고리즘 2022. 3. 31. 16:57
코드 let inputT = Int(readLine()!)! for i in 1...inputT { let inputNum = (readLine()?.split(separator: " ").map { Int($0)! })! print("Case #\(i): \(inputNum[0]) + \(inputNum[1]) = \(inputNum[0] + inputNum[1])") } https://www.acmicpc.net/problem/11022 11022번: A+B - 8 각 테스트 케이스마다 "Case #x: A + B = C" 형식으로 출력한다. x는 테스트 케이스 번호이고 1부터 시작하며, C는 A+B이다. www.acmicpc.net
-
[백준 11021][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력 -7알고리즘 2022. 3. 31. 16:52
코드 let inputT = Int(readLine()!)! for i in 1...inputT { let inputNum = (readLine()?.split(separator: " ").map { Int($0)! })! print("Case #\(i): \(inputNum[0] + inputNum[1])") } https://www.acmicpc.net/problem/11021 11021번: A+B - 7 각 테스트 케이스마다 "Case #x: "를 출력한 다음, A+B를 출력한다. 테스트 케이스 번호는 1부터 시작한다. www.acmicpc.net
-
[백준 10953][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력 -6알고리즘 2022. 3. 31. 16:48
코드 let inputT = Int(readLine()!)! for _ in 1...inputT { let inputNum = (readLine()?.split(separator: ",").map { Int($0)! })! print(inputNum[0] + inputNum[1]) } https://www.acmicpc.net/problem/10953 10953번: A+B - 6 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net
-
[백준 10952][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력 -5알고리즘 2022. 3. 31. 16:42
코드 while let input = readLine() { let inputNumber = input.split(separator: " ").map { Int($0)! } if inputNumber[0] != 0 && inputNumber[1] != 0 { print(inputNumber[0] + inputNumber[1]) } else { break } } https://www.acmicpc.net/problem/10952 10952번: A+B - 5 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net
-
[백준 10951][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력 -4알고리즘 2022. 3. 31. 16:08
코드 while let input = readLine() { let inputNumber = input.split(separator: " ").map { Int($0)! } print(inputNumber[0] + inputNumber[1]) } EOF(End Of File) 문제 무한루프가 돌 때 어떻게 빠져나올지 묻는 문제 while true { ... } readLine() 자체를 true인지 false 인지 판단 control + d 로 빠져나오거나 enter 치면 빠져나옴 https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net
-
[백준 10950][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력 -3카테고리 없음 2022. 3. 31. 14:39
코드 let inputT = Int(readLine()!)! for _ in 1...inputT { let inputNum = readLine()?.split(separator: " ") let a = Int(inputNum?.first ?? "0")! let b = Int(inputNum?.last ?? "0")! print(a + b) } 혹은 map 메소드 이용 let inputT = Int(readLine()!)! for _ in 1...inputT { let inputNum = (readLine()?.split(separator: " ").map { Int($0)! })! print(inputNum[0] + inputNum[1]) } https://www.acmicpc.net/problem/10..