Python to Swift
for 문
2739_구구단
n = int(input())
for i in range(1, 10):
print("{} * {} = {}".format(n, i, n*i))
import Foundation
if let tempN = readLine() {
let n = Int(tempN)!
for i in 1...9 {
print("\(n) * \(i) = \(n * i)")
}
}
10950_A+B-3
a = int(input())
for _ in range(a):
b, c = map(int, input().split())
print(b+c)
import Foundation
if let tempT = readLine() {
if let t = Int(tempT) {
for _ in 1...t {
if let inputLine = readLine() {
let inputLineArray = inputLine.components(separatedBy: " ")
if let a = Int(inputLineArray[0]), let b = Int(inputLineArray[1]) {
print(a + b)
}
}
}
}
}
8393_합
n = int(input())
print(int(n*(n+1)/2))
import Foundation
let n = Int(readLine()!)!
print(n*(n+1)/2)
2741_N 찍기
a = int(input())
for i in range(1, a+1):
print(i)
let n = Int(readLine()!)!
for i in 1...n {
print(i)
}
2741_기찍 N
n = int(input())
for i in range(n, 0, -1):
print(i)
let n = Int(readLine()!)!
for i in stride(from: n, through: 1, by: -1) {
print(i)
}
11021_A+B-7
a = int(input())
for i in range(1, a+1):
b, c = map(int, input().split())
print("Case #{}: {}".format(i, b+c))
import Foundation
if let tempT = readLine() {
if let t = Int(tempT) {
for i in 1...t {
if let inputLine = readLine() {
let inputLineArray = inputLine.components(separatedBy: " ")
if let a = Int(inputLineArray[0]), let b = Int(inputLineArray[1]) {
print("Case #\(i): \(a + b)")
}
}
}
}
}
11022_A+B-8
a = int(input())
for i in range(1, a+1):
b, c = map(int, input().split())
print("Case #{}: {} + {} = {}".format(i, b, c, b+c))
import Foundation
if let tempT = readLine() {
if let t = Int(tempT) {
for i in 1...t {
if let inputLine = readLine() {
let inputLineArray = inputLine.components(separatedBy: " ")
if let a = Int(inputLineArray[0]), let b = Int(inputLineArray[1]) {
print("Case #\(i): \(a) + \(b) = \(a + b)")
}
}
}
}
}
2438_별 찍기 - 1
n = int(input())
for i in range(1,n+1):
print('*'*i)
let n = Int(readLine()!)!
for i in 1...n {
for _ in 1 ... i {
print("*", terminator: "")
}
print()
}
2439_별 찍기 - 2
n = int(input())
for i in range(1,n+1):
print(' ' * (n-i) + '*' * i)
let n = Int(readLine()!)!
for i in 1...n {
if i < n {
for _ in 1...n-i {
print(" ", terminator: "")
}
}
for _ in 1...i {
print("*", terminator: "")
}
print()
}
10871_X 보다 작은 수
n, x = map(int, input().split())
li_a = list(map(int, input().split()))
for a in li_a:
if a < x:
print(a, end=' ')
import Foundation
let inputLine = readLine()!.components(separatedBy: " ")
let n = Int(inputLine[0])!
let x = Int(inputLine[1])!
let inputLineOfN = readLine()!
.components(separatedBy: " ")
.map { Int($0)! }
.filter { $0 < x }
for i in inputLineOfN {
print(i, terminator: " ")
}