LoginSignup
0
0

More than 3 years have passed since last update.

Swift 5.3.2 ver での入出力Sample

Posted at

ver. Swift 5.3.2

備忘録: Swift 値の入出力

入力受け取り
// -> Hello, World!!
let tmp = readLine()!

// -> 19990809
var my_birth = Int(readLine()!)!

// -> 20210518 
my_birth = Int(readLine()!)! // <- update value

// 複数行の場合
// -> John/Bob/Alice/Billy
let employee: [String] = readLine()!.components(separatedBy: "/")

// -> 34 29 21 23
let age: [Int] = readLine()!.components(separatedBy: " ").map { Int($0)! }
出力

// print(***)での出力は改行が入ります。

print(tmp)
// -> Hello, World!!

print(my_birth)
// -> 20210518

print(employee[0] + " " + age[0])
// -> John 34
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0