fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, const char * argv[])
  7. {
  8. int a[] = { 3, 5, 12, 1, 48, 2, 4 };
  9.  
  10. for(auto& i: a)
  11. {
  12. swap(i,*min_element(&i,end(a)));
  13. }
  14.  
  15. for(auto i: a) cout << i << " ";
  16.  
  17. }
  18.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
1  2  3  4  5  12  48