Created
August 26, 2012 20:38
-
-
Save fsouza/3483446 to your computer and use it in GitHub Desktop.
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> | |
void | |
bubble(int v[], int size) | |
{ | |
for(int i = size-1; i >= 1; i--) { | |
int aux; | |
for(int j = i; j >= 0; j--) { | |
if(v[i] < v[j]) { | |
aux = v[i]; | |
v[i] = v[j]; | |
v[j] = aux; | |
} | |
} | |
} | |
} | |
int | |
main(void) | |
{ | |
int v[] = {5, 4, 2, 10, 30, 8}; | |
bubble(v, 6); | |
for(int i = 0; i < 6; i++) { | |
std::cout << v[i] << " "; | |
} | |
std::cout << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment