Skip to content

Instantly share code, notes, and snippets.

@abrarShariar
Created February 1, 2016 12:47
Show Gist options
  • Save abrarShariar/50a8c47c4a85914d3651 to your computer and use it in GitHub Desktop.
Save abrarShariar/50a8c47c4a85914d3651 to your computer and use it in GitHub Desktop.
Bubble sorting in C++
#include<iostream>
using namespace std;
int main(){
int arr[]={9,4,3,12,8,0};
int sz=6;
for(int i=0;i<sz;i++){
for(int j=0;j<sz;j++){
if(arr[j]>arr[j+1]){
int temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
//print
for(int i=0;i<6;i++){
cout<<arr[i]<<endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment