fun _w(name: String, firstValue: String, secondValue: String): String {
val lastName = name[name.length - 1]
if (lastName.toInt() < 0xAC00 || lastName.toInt() > 0xD7A3) return name
val seletedValue = if ((lastName.toInt() - 0xAC00) % 28 > 0) firstValue else secondValue
return name + seletedValue
}
fun main() {
val text = "${_w("컴퓨터", "은", "는")} ${_w("키보드", "이", "가")} ${_w("우리", "을", "를")} 돕는다."
println(text)
}
결과는 다음과 같다.
이 컴퓨터는 키보드가 우리를 돕는다.
