Bibi's DevLog ๐Ÿค“๐ŸŽ

[๋ฐฑ์ค€ 2562] ์ตœ๋Œ“๊ฐ’ (Swift) ๋ณธ๋ฌธ

ํ”„๋กœ๊ทธ๋ž˜๋ฐ/์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€์ด Swift

[๋ฐฑ์ค€ 2562] ์ตœ๋Œ“๊ฐ’ (Swift)

๋น„๋น„ bibi 2022. 9. 14. 15:10

https://www.acmicpc.net/problem/2562

 

2562๋ฒˆ: ์ตœ๋Œ“๊ฐ’

9๊ฐœ์˜ ์„œ๋กœ ๋‹ค๋ฅธ ์ž์—ฐ์ˆ˜๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ, ์ด๋“ค ์ค‘ ์ตœ๋Œ“๊ฐ’์„ ์ฐพ๊ณ  ๊ทธ ์ตœ๋Œ“๊ฐ’์ด ๋ช‡ ๋ฒˆ์งธ ์ˆ˜์ธ์ง€๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์„œ๋กœ ๋‹ค๋ฅธ 9๊ฐœ์˜ ์ž์—ฐ์ˆ˜ 3, 29, 38, 12, 57, 74, 40, 85, 61 ์ด ์ฃผ์–ด

www.acmicpc.net

 

var maxNum = 0
var maxIndex = 0
(1...9).forEach { index in
    let input = Int(readLine()!)!
    if input > maxNum {
        maxNum = input
        maxIndex = index
    }
}
print(maxNum, maxIndex, separator: "\n")