-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
29 lines (26 loc) · 783 Bytes
/
Solution.java
File metadata and controls
29 lines (26 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class Solution {
private static final Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int n = scan.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = scan.nextInt();
}
scan.close();
plusMinus(arr);
}
static void plusMinus(int[] arr) {
double pos = 0;
double neg = 0;
double z = 0;
for (int num : arr) {
if (num > 0) pos++;
else if (num < 0) neg++;
else z++;
}
System.out.printf("%.6f%n", pos / arr.length);
System.out.printf("%.6f%n", neg / arr.length);
System.out.printf("%.6f%n", z / arr.length);
}
}