fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n;
  7. int a[n];
  8. for(int i=0;i<n;i++)
  9. cin>>a[i];
  10. for(int i=0;i<n;i++) {
  11. int minIndex=i;
  12. for(int j=i;j<n;j++) {
  13. if(a[j]<a[minIndex])
  14. minIndex=j;
  15. }
  16. int temp=a[i];a[i]=a[minIndex];a[minIndex]=a[i];
  17. }
  18. for(int i=0;i<n;i++)
  19. cout<<a[i]<<" ";
  20. return 0;
  21. }
Success #stdin #stdout 0s 5316KB
stdin
5 4 3 2 1 
stdout
Standard output is empty