Created
September 18, 2018 14:45
-
-
Save mochow13/462c9721043456b2419b5a102ad8e44a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a=9, b=12; | |
// out.first contains the minimum element, out.second is the maximum one | |
auto out=std::minmax(a,b); | |
std::vector<int> collection={6,5,3,2,1,4,6,7}; | |
auto result=std::minmax_element(begin(collection), end(collection)); | |
// you can also add compare function as the third argument | |
// (result.first - collection.begin()) is the index of the minimum element | |
// (result.second - collection.begin()) is the index of the maximum element |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment