题解 | #学生基本信息输入输出# Scala解法

学生基本信息输入输出

http://www.nowcoder.com/practice/58b6a69b4bf943b49d2cd3c15770b9fd

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val line: String = StdIn.readLine()
    // 正则指定两种分隔符,用 | 隔开
    val strs: Array[String] = line.split(";|,")
    val id: String = strs(0)
    val score1: Float = strs(1).toFloat
    val score2: Float = strs(2).toFloat
    val score3: Float = strs(3).toFloat
    println("The each subject score of  No. %s is %.2f, %.2f, %.2f.".format(id, score1, score2, score3))
  }
}
全部评论

相关推荐

如题,这操作。。。。
真烦好烦真烦:既想享受国家的招聘应届生福利,又不想培养新人,我只能说这种企业的ld太过分了
投递美的集团等公司6个岗位 >
点赞 评论 收藏
分享
谁知道呢_:你好,我是炮灰n+1号
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务