Created
March 19, 2018 08:02
-
-
Save h0hmj/22841742f531a3eae4a1966cf7105577 to your computer and use it in GitHub Desktop.
bubble sort
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 <utility> | |
#include <vector> | |
void bubble_sort(std::vector<int>& nums) { | |
for (int i = 0; i < nums.size(); i++) { | |
for (int j = nums.size() - 1; j > i; j--) { | |
if (nums[j] < nums[i]) { | |
std::swap(nums[i], nums[j]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment