Plus Minus

  • + 0 comments

    C++11

    /* * Complete the 'plusMinus' function below. * * The function accepts INTEGER_ARRAY arr as parameter. */

    void plusMinus(vector arr) { float positive = 0, negative = 0, zero = 0; int total = arr.size();

    for(int i=0; i<total; i++){
        if(arr[i]>0){
            positive++;
        }
        else if(arr[i]<0){
            negative++;
        }
        else{
            zero++;
        }
    }
    cout<< positive/total <<endl;
    cout<< negative/total <<endl;
    cout<< zero/total <<endl;
    

    }