Skip to content

Instantly share code, notes, and snippets.

@olupotd
Created December 5, 2013 14:31
Show Gist options
  • Save olupotd/7805987 to your computer and use it in GitHub Desktop.
Save olupotd/7805987 to your computer and use it in GitHub Desktop.
Bubble sort in C++
#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