题解 | 斗兽棋

斗兽棋

https://www.nowcoder.com/practice/0b5afb815f6848d9a7f9c1b0ce514b95

import java.util.Scanner

fun main(args: Array<String>) {
    val read = Scanner(System.`in`)
    val (niuniu , niumei) = read.nextLine()!!.split(" ")
    val result = determin(niuniu,niumei)
    println(result)
}
fun determin(s1:String,s2:String):String{
 val beats = mapOf(
        "elephant" to "tiger",
        "tiger" to "cat",
        "cat" to "mouse",
        "mouse" to "elephant"
    )
    return when {
        beats[s1] == s2 -> "win"
        beats[s2] == s1 -> "lose"
        else -> "tie"
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务