Diana의 iOS 개발일기

[백준 swift] for문 - 2739번, 2741번, 10871번 본문

알고리즘/백준

[백준 swift] for문 - 2739번, 2741번, 10871번

Diana_iOS 2021. 3. 23. 19:06

2739번

import Foundation

let num: Int = Int(readLine()!)!
for var multi in 1...9 {
    print("\(num) * \(multi) = \(num * multi)")
}

2741번

import Foundation

let num = Int(readLine()!)!
for var pNum in 1...num {
    print(pNum)
}

10871번

import Foundation

var num = (readLine() ?? "").components(separatedBy: " ")
var writtenArr = (readLine() ?? "").components(separatedBy: " ")

var result = writtenArr.filter{Int($0)! < Int(num[1])!}.joined(separator: " ")

print(result)