Closed feldblume5263 closed 2 years ago
var n = readLine()!.split(separator: " ").map { Int($0)! }
for i in 0 ..< n.count {
if i <= 1 {
n[i] = 1 - n[i]
} else if i < 5 {
n[i] = 2 - n[i]
} else {
n[i] = 8 - n[i]
}
print(n[i], terminator: " ")
}
10818 min 함수와 max 함수를 쓰면 더 간단할 것 같다!
Int(readLine()!)!
let ns = readLine()!.split(separator: " ").map{ Int($0)!}
var l = ns[0]
var s = ns[0]
for n in ns {
if n > l { l = n }
if n < s { s = n }
}
print("\(s) \(l)")
var l = 0
var li = 0
for i in 1...9 {
let inp = Int(readLine()!)!
if l < inp {
l = inp
li = i
}
}
print("\(l)\n\(li)")
var a = [Int]()
for _ in 0..<10 {
let n = Int(readLine()!)! % 42
if a.firstIndex(of: n) == nil {
a.append(n)
}
}
print(a.count)
let c = Double(readLine()!)!
let n = readLine()!.split(separator: " ").map{ Double($0)! }
let h = n.max()!
print(n.map{ $0 / h * 100}.reduce(0, +) / c)
1시간 동안 문제 풀기 재미보다는 가독성과 시간복잡도를 더 신경쓰자.