SWIFT
UP and DOWN Number Game
HiroDaegu
2022. 11. 5. 00:25
728x90
SMALL

import Foundation
var comChoice = Int.random(in: 1...100)
var myChoice: Int = 0
print("컴퓨터가 선택한 숫자 맞추기")
while true {
var myInput = readLine()
print("당신의 입력한 숫자: \(myInput!)")
if let input = myInput {
if let num = Int(input) {
myChoice = num
}
}
if(comChoice > myChoice) {
print("UP")
myChoice = 0
} else if (comChoice < myChoice) {
print("DOWN")
myChoice = 0
} else {
print("BINGO")
break
}
}728x90
LIST