题解 | #学生基本信息输入输出# 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))
  }
}
全部评论

相关推荐

03-02 10:51
邵阳学院 Java
红鲤鱼与绿鲤鱼i:看了你的头像不像找工作,像在找妹子
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务