标签:int 总成绩 avg ola value lan func get UNC
func main (){
sum,avg,count := GetScore(90,82.5,73,64.8)
fmt.Printf("学员共有 %d 门成绩,总成绩是 %0.2f ,平均成绩为 :%0.2f",count,sum,avg)
fmt.Println()
scores := []float64{92,72.5,74.5,89,87,74}
sum, avg, count = GetScore(scores...)
fmt.Printf("学员共有 %d 门成绩,总成绩是 %0.2f ,平均成绩为 :%0.2f",count,sum,avg)
}
func GetScore(scores ...float64) (sum,avg float64,count int) {
for _,values := range scores{
sum += values
count++
}
avg = sum/ float64((count))
return
}
标签:int 总成绩 avg ola value lan func get UNC
原文地址:https://www.cnblogs.com/wangcc7/p/12892087.html