Skip to content

Instantly share code, notes, and snippets.

@MoltenCoreDev
Created September 3, 2023 20:16
Show Gist options
  • Save MoltenCoreDev/566d3fbc89febfc7bd71825d19958b03 to your computer and use it in GitHub Desktop.
Save MoltenCoreDev/566d3fbc89febfc7bd71825d19958b03 to your computer and use it in GitHub Desktop.
BubbleSort in c++, for testing in comp coding or smth
#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