Advertisement
Rakibul_Ahasan

Bubble_sort

Oct 14th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 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.     for(int i=0;i<6;i++){
  9.         for(int j=0;j<6-i-1;j++){
  10.             if(array[j]>array[j+1]){
  11.                 int temp=array[j+1];
  12.                 array[j+1]=array[j];
  13.                 array[j]=temp;
  14.             }
  15.         }
  16.     }
  17.  
  18.     for(int i=0;i<6;i++){
  19.         cout<<array[i]<<" ";
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement