Plus Minus

  • + 0 comments
    #include <bits/stdc++.h>
    using namespace std;
    
    void plusMinus(vector<int> arr) {
        int n = arr.size(), pos = 0, neg = 0, zero = 0;
        for (int x : arr) pos += x > 0, neg += x < 0, zero += x == 0;
        cout << fixed << setprecision(6) << (double)pos / n << endl << (double)neg / n << endl << (double)zero / n << endl;
    }
    
    int main() {
        int n; cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++) cin >> arr[i];
        plusMinus(arr);
        return 0;
    }