[1단계] 입출력과 사칙연산

2557 - Hello World

print("Hello World!")

1000 A+B

let input = readLine()!.split(separator: " ").map { Int($0)! }
print("\(input[0] + input[1])")

1001 A-B

let input = readLine()!.split{ $0 == " "}.map { Int($0)! }
print(input[0] - input[1])

10998 AxB

print(readLine()!.split{ $0 == " " }.map { Int($0)! }.reduce(1, *))

1008 A/B

let input = readLine()!.split{ $0 == " " }.map { Double($0)! }
print(input[0] / input[1])

10869 사칙연산

let input = readLine()!.split{ $0 == " " }.map { Int($0)! }
let (a, b) = (input[0], input[1])
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a % b)

10926 ??!

print(readLine()! + "??!")

18108 1998년생인 내가 태국에서는 2541년생?!

print(Int(readLine()!)! - 543)

10430 나머지

let input = readLine()!.split { $0 == " " }.map { Int($0)! }, (a, b, c) = (input[0], input[1], input[2])
[(a+b)%c, (a+b)%c, (a*b)%c, (a*b)%c].forEach { print($0) }// Some code

2588 곱셈

let num1 = Int(readLine()!)!
let num2 = Int(readLine()!)!
let num2Arr = String(num2).map { Int(String($0))! }.reversed()
var result = num2Arr.map { $0 * num1 }
result.append (num1 * num2)
result.forEach { print($0) }

11382 꼬마 정민

print(readLine()!.split { $0 == " " }.map { Int($0)! }.reduce(0, +))

10171 고양이

print(#"""
\    /\
 )  ( ')
(  /  )
 \(__)|
"""#)

10172 개

print(#"""
|\_/|
|q p|   /}
( 0 )"""\
|"^"`    |
||_/=\\__|
"""#)

Last updated