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

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

代码示例1
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)
}