package main

import "fmt"

func main(){
    sum:=0.0
    avg:=0.0
    xs:="123243"
    switch len(xs){
        case 0:
        avg=0
        default:
        for _,v:=range xs{
            sum+=float64(v)
        }
        avg=sum/float64(len(xs))
    }
    
    fmt.Println(float64(len(xs)))
    
    fmt.Println(sum)
    
    _=avg;
    fmt.Println(avg)
    
}

 

posted on 2016-01-16 09:00  王洪洪  阅读(1031)  评论(0编辑  收藏  举报