Created
September 3, 2023 20:16
-
-
Save MoltenCoreDev/566d3fbc89febfc7bd71825d19958b03 to your computer and use it in GitHub Desktop.
BubbleSort in c++, for testing in comp coding or smth
This file contains hidden or 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> | |
// Paste this at the top of the file | |
void bubbleSort(int* arr, int size); | |
// This at the bottom | |
void bubbleSort(int* arr, int size) { | |
for (int i = 0; i < size - 1; i++) { | |
for (int i = 0; i < size - 1; i++) | |
{ | |
if (arr[i] > arr[i + 1]) { | |
int buffer; | |
buffer = arr[i+1]; | |
arr[i+1] = arr[i]; | |
arr[i] = buffer; | |
} | |
else { | |
continue; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment