fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int a[]={28,3,30,2,29};
  7. int cur_min;
  8. for(int i=0;i<3;i++)
  9. {
  10. cur_min=i;
  11. for(int j=i+1;j<5;j++)
  12. {
  13. if(a[j]<a[cur_min])
  14. {
  15. cur_min=j;
  16. }
  17.  
  18.  
  19. }
  20. swap(a[i],a[cur_min]);
  21. }
  22. for(int i=0;i<5;i++)
  23. {
  24. cout<<a[i]<<" ";
  25. }
  26.  
  27. }
Success #stdin #stdout 0.01s 5424KB
stdin
Standard input is empty
stdout
2 3 28 30 29