6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift2でズンドコキヨシ

Last updated at Posted at 2016-03-15

初投稿です。
そんなに綺麗でもないけど、とりあえず元ネタに感化されて、書いてみました。

zundoko.swift
import UIKit
let array = ["ズン", "ドコ"]
var zun = 0
while true {
    let a = Int(arc4random_uniform(2))
    print(array[a])
    if a == 0  {
        zun += 1
    }
    else if a == 1 && zun == 4 {
        break
    }
    else{
        zun = 0
    }
}
print("キ・ヨ・シ!!")

インクリメントはあえて使わないように書いています。Swift3で廃止されそうなので

実行結果

スクリーンショット 2016-03-15 19.20.08.png

もう少し綺麗に書けないですかね...
修行が足りない気がします。

6
5
2

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
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?