Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void bubbleSort(list<int> arr) {
- int i;
- int j;
- int tmp;
- for (i = 0; i < #arr-1; i++) {
- for (j = 0; j < #arr-i-1; j++) {
- if (arr[j] > arr[j+1]) {
- tmp = arr[j];
- arr[j] = arr[j+1];
- arr[j+1] = tmp;
- }
- }
- }
- }
- int main() {
- list<int> a;
- int i;
- a = [10, 2, 15, 8, 20, 13, 9];
- bubbleSort(a);
- for(i = 0; i < #a; ++i) {
- printi(a[i]);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment