• + 0 comments

    No need to set the amount of decimals, it recognises the answers without needing the precise decimal point

    void plusMinus(vector<int> arr) {
        
        int maxNumber = arr.size();
        float zeroCount {0.0f};
        float posCount {0.0f};
        float negCount {0.0f}; 
        
        for(int i = 0; i < maxNumber; i++)
        {
            if (arr[i] == 0 )
            {
                
                zeroCount++;
                
            }    
            if (arr[i] > 0)
            {
                
                posCount++;
                
            }
            else if (arr[i] < 0)
            {
                
               negCount++; 
                
            }
            
        }
        
            std::cout << posCount/maxNumber << std::endl;
            std::cout << negCount/maxNumber << std::endl;
            std::cout << zeroCount/maxNumber << std::endl;
            
    }