add: unfinished code. people are having problems
This commit is contained in:
29
14-arrays/_experimental/11-avg/solution-slices/main.go
Normal file
29
14-arrays/_experimental/11-avg/solution-slices/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
args := os.Args[1:]
|
||||
|
||||
var (
|
||||
sum float64
|
||||
nums []float64
|
||||
)
|
||||
|
||||
for _, v := range args {
|
||||
n, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
nums = append(nums, n)
|
||||
sum += n
|
||||
}
|
||||
|
||||
fmt.Println("Your numbers:", nums)
|
||||
fmt.Println("Average:", sum/float64(len(nums)))
|
||||
}
|
||||
Reference in New Issue
Block a user