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
相关推荐
青柠代码录几秒前
【MySQL】事务:如何使用事务猫墨*几秒前
springboot3、knife4j-openapi3配置动态接口版本管理weixin_531651811 分钟前
Python 渐进式学习指南weixin_649555673 分钟前
C语言程序设计第四版(何钦铭、颜晖)第八章指针之在数组中查找指定元素add45a7 分钟前
C++中的原型模式代码s贝多芬的音符7 分钟前
Android NV21 转 YUV 系列格式2401_844221328 分钟前
C++类型推导(auto/decltype)2201_753877799 分钟前
高性能计算中的C++优化无限进步_9 分钟前
深入解析C++容器适配器:stack、queue与deque的实现与应用2501_945425159 分钟前
分布式系统容错设计