Skip to content

Instantly share code, notes, and snippets.

@gitboo
Last active June 4, 2019 02:00
Show Gist options
  • Select an option

  • Save gitboo/f3e37547073d4ffa32f7c2e385483b6a to your computer and use it in GitHub Desktop.

Select an option

Save gitboo/f3e37547073d4ffa32f7c2e385483b6a to your computer and use it in GitHub Desktop.
static void plusMinus(int[] arr) {
double size = arr.length;
double positive = 0f;
double negative = 0f;
double zero = 0f;
for (int i : arr) {
if (i > 0) {
positive++;
} else if (i == 0) {
zero++;
} else {
negative++;
}
}
System.out.println(positive / size);
System.out.println(negative / size);
System.out.println(zero / size);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment