You are viewing a single comment's thread. Return to all comments →
static void plusMinus(int[] arr) { int dimension = arr.length; double positives = 0; double negatives = 0; double zeros = 0; for (int i = 0; i < dimension; i++) { if (arr[i] > 0) { positives++; } else if (arr[i] < 0) { negatives++; } else { zeros++; } } positives /= dimension; negatives /= dimension; zeros /= dimension; System.out.printf("%.6f\n%.6f\n%.6f\n", positives, negatives, zeros); }
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 →