random

๐ŸŒฑ ์ฝ”๋ฆฐ์ด๋ฅผ ์œ„ํ•œ GUIDE/๐Ÿ—‚๏ธ OpenSource

16 Swift๋กœ ๋žœ๋ค๋น™๊ณ  ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ

16 ๋žœ๋ค๋น™๊ณ  ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ ๋ฌธ์ œ ํ’€์ด import UIKit var computer:Int = Int.random(in: 1...10) var user:Int = 5 if computer == user { print("Bingo") } else if computer user { print("Up") }

๐ŸŒฑ ์ฝ”๋ฆฐ์ด๋ฅผ ์œ„ํ•œ GUIDE/๐Ÿ—‚๏ธ OpenSource

15 Swift๋กœ ๊ฐ€์œ„๋ฐ”์œ„๋ณด ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ

15 ๊ฐ€์œ„๋ฐ”์œ„๋ณด ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ ๋ฌธ์ œ ํ’€์ด import UIKit var user:Int = Int.random(in: 0...2) var computer:Int = Int.random(in: 0...2) // 0 : ๋ฐ”์œ„ 1: ๊ฐ€์œ„ 2: ๋ณด //Switch๋ฌธ ์ด์šฉ switch user{ case 0: print("๋‹น์‹ ์€ ๋ฐ”์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") case 1: print("๋‹น์‹ ์€ ๊ฐ€์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค") case 2: print("๋‹น์‹ ์€ ๋ณด๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") default: break } switch computer{ case 0: print("์ปดํ“จํ„ฐ๋Š” ๋ฐ”์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") case 1: print("์ปดํ“จํ„ฐ๋Š” ๊ฐ€์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") case 2: print("์ปดํ“จํ„ฐ๋Š” ๋ณด๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") default: break } /..

์–‘์ฝฉ(Yangkong)
'random' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก