-
Kotlin π¬ λ°±μ€ 2λ¨κ³ :: 9498 λ²2023. 3. 15. 21:56λ°μν
μν μ±μ
λ¬Έμ |
μν μ μλ₯Ό μ λ ₯λ°μ 90 ~ 100μ μ A, 80 ~ 89μ μ B, 70 ~ 79μ μ C, 60 ~ 69μ μ D, λλ¨Έμ§ μ μλ Fλ₯Ό μΆλ ₯νλ νλ‘κ·Έλ¨μ μμ±νμμ€.
μ λ ₯ |
첫째 μ€μ μν μ μκ° μ£Όμ΄μ§λ€. μν μ μλ 0λ³΄λ€ ν¬κ±°λ κ°κ³ , 100λ³΄λ€ μκ±°λ κ°μ μ μμ΄λ€.
μΆλ ₯ |
μν μ±μ μ μΆλ ₯νλ€.
νμ΄ |
1) Scannerλ₯Ό μ΄μ©ν΄ μ λ ₯μ λ°μ μΆλ ₯ [120ms]
2) readLine()μ μ΄μ©ν΄ μ λ ₯μ λ°μ μΆλ ₯ [92ms]
λ΅μ |
import java.util.Scanner fun main() = with(Scanner(System.`in`)) { val score = nextInt() when(score) { in 90 .. 100 -> print("A") in 80 until 90 -> print("B") in 70 until 80 -> print("C") in 60 until 70 -> print("D") else -> print("F") } }
fun main() { val score = readLine()!!.toInt() when(score) { in 90 .. 100 -> print("A") in 80 until 90 -> print("B") in 70 until 80 -> print("C") in 60 until 70 -> print("D") else -> print("F") } }
λ°μν'π Algorithm > π λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
Kotlin π¬ λ°±μ€ 2λ¨κ³ :: 14681 λ² (0) 2023.03.17 Kotlin π¬ λ°±μ€ 2λ¨κ³ :: 2753 λ² (0) 2023.03.16 Kotlin π¬ λ°±μ€ 2λ¨κ³ :: 1330 λ² (0) 2023.03.14 Kotlin π¬ λ°±μ€ 1λ¨κ³ :: 10172 λ² (0) 2023.03.13 Kotlin π¬ λ°±μ€ 1λ¨κ³ :: 10171 λ² (0) 2023.03.12