min_element is supposed to return a pointer pointing to the minimum element in a array or vector but here why is it returning a position of the element with minimum value.
int n; cin>>n;
vector<int> arr(n);
for(int i=0;i<n;i++)
cin>>arr[i];
int minElementIndex = min_element(arr.begin(),arr.end()) - arr.begin();
cout<<minElementIndex;
Aucun commentaire:
Enregistrer un commentaire