fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. int arr[] = {71, 70, 10, 6, 50, 30, 35, 99, 49, 23, 39, 46, 22, 19, 52, 2};
  6.  
  7. int arrSize = sizeof(arr)/sizeof(arr[0]);
  8.  
  9. int mn = 100, temp, s_index, f_index;
  10. for(int i=0; i<arrSize-1; i++){
  11. f_index = i;
  12. for(int j=i+1; j<arrSize; j++){
  13. if(mn > arr[j]){
  14. mn = arr[j];
  15. s_index = j;
  16. }
  17. }
  18. if(arr[f_index] > arr[s_index]){
  19. temp = arr[s_index];
  20. arr[s_index] = arr[f_index];
  21. arr[f_index] = temp;
  22. }
  23. mn = 100;
  24. }
  25.  
  26. for(int i=0; i<arrSize; i++){
  27. cout<<arr[i]<<" ";
  28. }
  29. cout<<endl;
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5508KB
stdin
Standard input is empty
stdout
2 6 10 19 22 23 30 35 39 46 49 50 52 70 71 99