fork download
  1. #include <vector>
  2. #include <algorithm>
  3. #include <iostream>
  4.  
  5. int main()
  6. {
  7. int arr[] = {3,5,4,12,1,4,7,2,6,5};
  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
12
7
6
5