Created
November 12, 2017 22:26
-
-
Save ldco2016/b70501055154930b6b321da8fcaa4f0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
var n = parseInt(readLine()); | |
arr = readLine().split(' '); | |
arr = arr.map(Number); | |
let positive = negative = zero = 0; | |
for (i =0; i < n; i++){ | |
let current = arr[i]; | |
if (current > 0) { | |
positive += 1; | |
} else if (current < 0) { | |
negative += 1; | |
} else { | |
zero += 1; | |
} | |
} | |
console.log((positive / n).toFixed(6)); | |
console.log((negative / n).toFixed(6)); | |
console.log((zero / n).toFixed(6)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment