Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename bubble sort #827

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: rename bubble sort
  • Loading branch information
yanglbme authored Jul 21, 2022
commit 0ec1de3613213f72fbca0a620e668fc54365aeff
31 changes: 31 additions & 0 deletions basic/sorting/BubbleSort/BubbleSort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>
#include <vector>

using namespace std;


void bubbleSort(vector<int>& arr)
{
int n = arr.size();
for (int i = 0; i < n - 1; ++i)
{
bool change = false;
for (int j = 0; j < n - i - 1; ++j)
{
if (arr[j] > arr[j + 1])
{
swap(arr[j], arr[j + 1]);
change = true;
}
}
if (!change) break;
}
}

int main()
{
vector<int> arr = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
bubbleSort(arr);
for (int v : arr) cout << v << " ";
cout << endl;
}
64 changes: 0 additions & 64 deletions basic/sorting/BubbleSort/bubblesort.cpp

This file was deleted.