mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
formatting source-code for e464ddac36
This commit is contained in:
parent
38db7fdec0
commit
11728ee231
@ -34,8 +34,7 @@
|
||||
*
|
||||
*/
|
||||
auto printArray = [](int *arr, int sz) {
|
||||
for (int i = 0 ; i < sz ; i++)
|
||||
std::cout << arr[i] <<" ";
|
||||
for (int i = 0; i < sz; i++) std::cout << arr[i] << " ";
|
||||
std::cout << "\n";
|
||||
};
|
||||
|
||||
@ -45,6 +44,8 @@ auto printArray = [] (int *arr, int sz) {
|
||||
* the bottom up by successively sifting downward to establish the
|
||||
* heap property.
|
||||
*
|
||||
* @param arr array be to sorted
|
||||
* @param
|
||||
*/
|
||||
void (*heapify)(int *arr, int n, int i) = [](int *arr, int n, int i) {
|
||||
int largest = i;
|
||||
@ -72,8 +73,7 @@ void(*heapify)(int *arr, int n, int i) = [] (int *arr, int n, int i) {
|
||||
*
|
||||
*/
|
||||
auto heapSort = [](int *arr, int n) {
|
||||
for (int i = n-1 ; i >= 0; i--)
|
||||
heapify(arr, n, i);
|
||||
for (int i = n - 1; i >= 0; i--) heapify(arr, n, i);
|
||||
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
std::swap(arr[0], arr[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user