백준
-
[백준 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..
-
[백준 1000][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력알고리즘 2022. 3. 31. 10:37
코드 import Foundation let input = readLine()?.components(separatedBy: " ") if let a = Int(input?.first ?? "0"), let b = Int(input?.last ?? "0") { print(a + b) } 혹은 let input = readLine()?.split(separator: " ") let first = Int(input?.first ?? "0")! let second = Int(input?.last ?? "0")! print(first + second) https://www.acmicpc.net/problem/1000 1000번: A+B 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. ..