You are viewing a single comment's thread. Return to all comments →
Kotlin Solution:
fun plusMinus(arr: Array<Int>): Unit { var zero: Double = 0.0 var positive: Double = 0.0 var negative: Double = 0.0 for (n in arr){ if (n > 0){ positive++ } else if (n <0){ negative++ } else { zero++ } } println(String.format("%.6f", (positive / arr.size).toDouble())) println(String.format("%.6f", (negative / arr.size).toDouble())) println(String.format("%.6f", (zero / arr.size).toDouble())) }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
Kotlin Solution: