一局游戏有好几轮(至少一轮),points 是每轮的得分。写 Rounds(points),一次返回总分和得分最高的那一轮。
Rounds([]int{4, 9, 2})→(15, 9)Rounds([]int{7})→(7, 7)func Rounds(points []int) (int, int)package main
func Rounds(points []int) (int, int) {
total, best := 0, points[0]
for _, p := range points {
// 在这里写:加进 total;比 best 大就换掉 best
}
return total, best
}
写好了先点「运行」试试示例,没问题再点「提交」。