Advertisement
Rakibul_Ahasan

Selection_Sort

Oct 14th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int array[]={45,23,78,45,78,90};
  7.  
  8.     int int_min;
  9.     for(int i=0;i<6-1;i++){
  10.         int_min=i;
  11.  
  12.         for(int j=i+1;j<6;j++){
  13.             if(array[j]<array[int_min]){
  14.                 int_min=j;
  15.             }
  16.         }
  17.         if(int_min!=i){
  18.             int temp=array[int_min];
  19.             array[int_min]=array[i];
  20.             array[i]=temp;
  21.         }
  22.     }
  23.  
  24.  
  25.      for( int i=0;i<6;i++){
  26.         cout<<array[i]<<" ";
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement