Created
December 5, 2013 14:31
-
-
Save olupotd/7805987 to your computer and use it in GitHub Desktop.
Bubble sort in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int numb[20]; | |
int i (0), j (0), temp; | |
int main(int argc, char* argv[]) | |
{ | |
while(i < sizeof(numb)){ | |
numb[i] = i+2; | |
i++; | |
} | |
for(i=0;i<=5;i++) | |
{ | |
for(j=i+1;j<=sizeof(numb);j++) | |
{ | |
int temp; | |
if(numb[i] > numb[j]) | |
{ | |
temp = numb[i]; | |
numb[i] = numb[j]; | |
numb[j] = temp; | |
} | |
} | |
} | |
for(i=0;i<=sizeof(numb);i++) | |
{ | |
cout << endl << numb[i] << endl; | |
} | |
cin.ignore(); | |
cin.get(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment