/**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
import kotlin.math.pow
fun main() {
var workstring = "天無絶人之路"
println(mid(workstring, 2, 5))
}
fun mid(txt:String, startnub:Int, nums:Int) : String {
return txt.substring(startnub, nums)
}
選我最佳解答
fun main() {
val workstring = "天無絶人之路"
println( mid(workstring, 2, 5) )
}
fun mid( text: String, start: Int, length: Int ) : String {
val end = kotlin.math.min( start + length, text.length )
return text.substring( start, end )
}