How can I get the max (or min) value in a vector?
问题 How can I get the max (or min) value in a vector in C++ ? I have seen a few solutions for this on Google but none of them made sense to me :( Can someone explain in an easy straightforward noob way how to get the max or min value from a vector please? and am I wrong in assuming it would be more or less the same with an array? I need an iterator right? I tried it with max_element but kept getting an error? vector<int>::const_iterator it; it = max_element(cloud.begin(), cloud.end()); error: