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
相关推荐
巫山老妖3 小时前
从零开发一个掘金自动发布 Skill,并上架 Clawhub颜酱4 小时前
图的数据结构:从「多叉树」到存储与遍历雨中飘荡的记忆5 小时前
零拷贝技术深度解析uzong5 小时前
十年老员工的项目管理实战心得:有道有术Victor3566 小时前
MongoDB(31)索引对查询性能有何影响?Victor3567 小时前
MongoDB(30)如何删除索引?lizhongxuan7 小时前
多 Agent 协同机制对比IT_陈寒7 小时前
SpringBoot项目启动慢?5个技巧让你的应用秒级响应!树上有只程序猿8 小时前
2026低代码选型指南,主流低代码开发平台排名出炉高端章鱼哥8 小时前
为什么说用OpenClaw对打工人来说“不划算”