fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int arr[7]={10,8,11,7,2,9,2};
  6. cout<<"selection sort\n";
  7.  
  8. for(int i=0;i<7;i++){
  9.  
  10. for(int j=1; j<7-1-i;j++){
  11.  
  12. if(arr[j]>arr[j+1]){
  13.  
  14. swap(arr[j],arr[j+1]);
  15. }
  16. }
  17. }
  18. for(int i=0;i<7;i++){
  19.  
  20. cout<<arr[i]<<" ";
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
selection sort
10 2 2 7 8 9 11