-
Notifications
You must be signed in to change notification settings - Fork 6
/
Solution.cpp
49 lines (35 loc) · 848 Bytes
/
Solution.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
float zero=0,pos=0,neg=0;
int i,size;
cin>>size;
float array[size];
for(i=0 ; i<size ; i++)
{
cin>>array[i];
}
for(i=0 ; i<size ; i++)
{
if(array[i]==0)
{
zero=zero+1;
}
else if(array[i]>0)
{
pos=pos+1;
}
else if(array[i]<0)
{
neg=neg+1;
}
}
float pos_ratio= pos/size;
float neg_ratio= neg/size;
float zero_ratio=zero/size;
cout << std::fixed << std::setprecision(6) << pos_ratio << endl;
cout << std::fixed << std::setprecision(6) << neg_ratio << endl;
cout << std::fixed << std::setprecision(6) << zero_ratio << endl;
}