[Solved] How do I compute absolute value of vector? [closed]


this code will help you, loop the vector and apply abs (function to find absolute value )

   for(unsigned int i = 0; i < numbers.size(); i++)
    {
        if(numbers[i] < 0)numbers[i] *= -1; //make positive.    _OR_   use numbers[i] = abs(numbers[i]);
        std::cout<<numbers[i]<<std::endl;
    }

2

solved How do I compute absolute value of vector? [closed]