package test_33
import scala.io.Source
//成绩分析
object test {
def main(args: Array[String]): Unit = {
//1.读入成绩,按行去读取
val it= Source.fromFile("score.txt").getLines().drop(1)
while (it.hasNext){
val content=it.next()
//使用中文的逗号去拆分字符串
var arr=content.split(",")
val name=arr(0)
val yuwen=arr(1).toInt
val shuxue=arr(2).toInt
val yingyu=arr(3).toInt
val total=yuwen+shuxue+yingyu
val avg=total / 3
println("当前行是",name,yingyu,total)
}
}
}
Scala中字符串
爱吃香菜---www2024-11-28 14:28
相关推荐
JIngJaneIL4 分钟前
基于springboot + vue房屋租赁管理系统(源码+数据库+文档)期待のcode25 分钟前
Java的抽象类和接口wadesir1 小时前
Go语言中高效读取数据(详解io包的ReadAll函数用法)千寻技术帮1 小时前
10422_基于Springboot的教务管理系统Victor3561 小时前
Hibernate(12)什么是Hibernate的实体类?Victor3561 小时前
Hibernate(11)什么是Hibernate的持久化上下文?小高不明1 小时前
前缀和一维/二维-复习篇龘龍龙1 小时前
Python基础(八)期待のcode2 小时前
@RequestBody的伪表单提交场景王中阳Go2 小时前
手把手教你用 Go + Eino 搭建一个企业级 RAG 知识库(含代码与踩坑)