20 lines
433 B
Swift
20 lines
433 B
Swift
if let input = readLine(),
|
|
let numbers = {
|
|
let tempNumbers = input.split(separator: " ").compactMap({Int($0)})
|
|
return tempNumbers.isEmpty ? nil : tempNumbers
|
|
}() {
|
|
|
|
var min = numbers[0]
|
|
var max = numbers[0]
|
|
|
|
for num in numbers {
|
|
min = min > num ? num : min
|
|
max = max < num ? num : max
|
|
}
|
|
|
|
print("\n최소값 : \(min)\n최대값 : \(max)\n")
|
|
|
|
} else {
|
|
print("error")
|
|
}
|