Created
June 24, 2020 20:17
-
-
Save irchimi/0441723040922244a21b6128589b375c to your computer and use it in GitHub Desktop.
BubbleSort 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
static void Swap(int& x, int& y) { | |
int swap = x; | |
x = y; | |
y = swap; | |
} | |
static void BubbleSort(int arr[], int length) { | |
for (int i = 0; i < length - 1; i++) { | |
for (int l = i + 1; l < length; l++) { | |
if (arr[i] < arr[l]) { | |
Swap(arr[i], arr[l]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment