If I have a vector v={1,2,4,6,8} and I find my maximum element of this vector using this:
"
vector<int>::iterator iter_max = max_element(v.begin(), v.end());
cout<<"Largest element is "<< *iter_max;
"
which works fine. But I need to know the position of this max element. Is it second, third or fourth in my vector structure? What is the position of my max element in my vector? Can anyone help please?
samm22
0
Newbie Poster
samm22
0
Newbie Poster
JasonHippy
739
Practically a Master Poster
JasonHippy
739
Practically a Master Poster
samm22
0
Newbie Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
JasonHippy
commented:
Very handy..Not seen distance used before!
+3
samm22
0
Newbie Poster
JasonHippy
739
Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.