I know how to get min and max value in a vector through iterators as shown below, But how about getting a min and max value of a matrix table in vectors of vector: for example i have:
vector<vector<float> > vec;
the above vector has a matrix (my program reads data from csv file and enters into these vectors of vector as a matrix) , such that i want to check a specific column in the vector of vector and find the min and max values in that particular column, keeping in mind that finding min and max from a specific column of a vector specified.
normal way to find min and max value in a single vector is :
int main()
{
std::vector<double> v {1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0};
auto biggest = std::max_element(std::begin(v), std::end(v));
std::cout << "Max element is " << *biggest
<< " at position " << std::distance(std::begin(v), biggest) << std::endl;
auto smallest = std::min_element(std::begin(v), std::end(v));
std::cout << "min element is " << *smallest
<< " at position " << std::distance(std::begin(v), smallest) << std::endl;
}
but what if the vector has another vector like vector<vector<float> > vec;