make the index of the maximum
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main( )
{
vector<int> v( 10, 66 );
v[1] = 100;
vector<int>::iterator before_itr = max_element( v.begin(), v.end() );
cout << "The maximum before resizing is " << *before_itr;
vector<int>::difference_type max_index = before_itr - v.begin();
}
Related examples in the same category