fork download
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. int main ( )
  5. {
  6. const int a[] = {0, 1, 42, -1, 4};
  7.  
  8. auto it = std::minmax_element(std::begin(a), std::end(a));
  9. std::cout << *it.first << " " << *it.second << std::endl;
  10. return 0;
  11. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
-1 42