mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update Bubble Sort.cpp
This commit is contained in:
parent
5f791fe619
commit
4f5f1f4225
@ -1,9 +1,7 @@
|
|||||||
//Bubble Sort
|
//Bubble Sort
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -16,7 +14,6 @@ int main()
|
|||||||
cout << "Enter " << n << " numbers: ";
|
cout << "Enter " << n << " numbers: ";
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
|
||||||
//Input
|
//Input
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -25,7 +22,6 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Bubble Sorting
|
//Bubble Sorting
|
||||||
|
|
||||||
for (int i = 0; (i < n) && (swap_check == 1); i++)
|
for (int i = 0; (i < n) && (swap_check == 1); i++)
|
||||||
{
|
{
|
||||||
swap_check = 0;
|
swap_check = 0;
|
||||||
@ -52,7 +48,7 @@ int main()
|
|||||||
cout << numbers[i] << endl;
|
cout << numbers[i] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*The working principle of the Bubble sort algorithm:
|
/*The working principle of the Bubble sort algorithm:
|
||||||
|
Loading…
Reference in New Issue
Block a user