-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathPlusMinus.java
More file actions
28 lines (26 loc) · 674 Bytes
/
Copy pathPlusMinus.java
File metadata and controls
28 lines (26 loc) · 674 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
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int neg=0;
int pos=0;
int zero=0;
int a;
int n = sc.nextInt();
for(int i=0;i<n;i++){
a = sc.nextInt();
if(a>0)
pos++;
else if(a<0)
neg++;
else
zero++;
}
float fp = (float)pos/n;
float fn = (float)neg/n;
float fz = (float)zero/n;
System.out.printf("%.3f\n",fp);
System.out.printf("%.3f\n",fn);
System.out.printf("%.3f\n",fz);
}
}