알고리즘
[백준 1000][Swift] 두 정수 A와 B를 입력받은 다음, A+B를 출력
moving
2022. 3. 31. 10:37
728x90
코드
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를 출력하는 프로그램을 작성하시오.
www.acmicpc.net