Problem:
Given two integers a and b, write code to print the equation format below.
a + b = c
https://school.programmers.co.kr/learn/courses/30/lessons/181947
Constraints:
- 1 ≤ a, b ≤ 100
Solution:
let n = readLine()!.components(separatedBy: [" "]).map { Int($0)! }
let (a, b) = (n[0], n[1])
let result = a + b
print("\(a) + \(b) = \(result)")
// 또는
// print(a, "+", b, "=", a + b)
문자열을 포맷에 맞춰 출력하는 문제입니다. 문자열에 직접 ()을 사용해서 변수를 출력할 수도 있고, 아래 주석처럼 콤마(,)로 나눠서 출력할 수도 있습니다.
](