• + 0 comments
    void plusMinus(vector<int> arr) {
    	int p = 0, n = 0, z = 0;
    	for(int el : arr){
    		if(el > 0) 
    			p++;
    		else if(el < 0) 
    			n++;
    		else 
    			z++;
    	}
    	double total = arr.size();
    	double pr = p / total;
    	double nr = n / total;
    	double zr = z / total;
    
    	// Set the output to print 6 decimal places
    	cout << fixed << setprecision(6);
    	// Print each result on a new line
    	cout << fixed << setprecision(6);
    	cout << pr << "\n" << nr << "\n" << zr;
    }