Closed feldblume5263 closed 2 years ago
let c = Int(readLine()!)!
var n: [[Int]] = []
for _ in 0..<c {
n.append(readLine()!.split(separator: " ").map { Int($0)! })
}
for idx in 0..<c {
print("Case #\(idx + 1): \(n[idx][0] + n[idx][1])")
}
let c = Int(readLine()!)!
var n: [[Int]] = []
for _ in 0..<c {
n.append(readLine()!.split(separator: " ").map { Int($0)! })
}
for idx in 0..<c {
print("Case #\(idx + 1): \(n[idx][0]) + \(n[idx][1]) = \(n[idx][0] + n[idx][1])")
}
let n = Int(readLine()!)!
for idx in 0..<n {
for _ in 1...idx + 1 {
print("*", terminator: "")
}
print("")
}
let n = Int(readLine()!)!
for idx in 1...n {
for _ in 0..<(n - idx) {
print(" ", terminator: "")
}
for _ in 1...idx {
print("*", terminator: "")
}
print("")
}
let nx = readLine()!.split(separator: " ").map { Int($0)! }
let input = readLine()!.split(separator: " ").map { Int($0)! }
var num: [Int] = []
for idx in 0..<nx[0] {
if input[idx] < nx[1] {
print(input[idx], terminator: " ")
}
}
while let line = readLine() {
let input = line.split(separator: " ").map { Int($0)! }
print(input[0] + input[1])
}
let n = Int(readLine()!)!
var k = n
var count = 0
while k != n || count == 0 {
count += 1
k = (k % 10) * 10 + (((k / 10) + (k % 10)) % 10)
}
print(count)
1시간 동안 문제 풀기 재미보다는 가독성과 시간복잡도를 더 신경쓰자.