📜  hackerrank golang plus minus - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:14.578000             🧑  作者: Mango

代码示例6
func plusMinus(arr []int32) {
    var positive, negative, zero, total float64
    total = float64(len(arr))
    
    for _, v := range arr {
        if v > 0 {
            positive++
        } else if  v < 0  {
            negative++
        } else {
            zero++
        }
    }
    
    fmt.Printf("%v\n", positive / total)
    fmt.Printf("%v\n", negative/ total)
    fmt.Printf("%v\n", zero / total)
}