fork download
  1. #include <vector>
  2. #include <algorithm>
  3. #include <iostream>
  4.  
  5. int main()
  6. {
  7. int arr[] = {2,3,1};
  8.  
  9. auto m = std::begin(arr);
  10. while (m != std::end(arr))
  11. {
  12. m = std::max_element(m, std::end(arr));
  13. std::cout << *(m++) << std::endl;
  14. }
  15. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
3
1