C++的快速排序怎么写

C 语言中的快速排序通常使用递归算法实现。下面是一个示例代码:

#include <stdio.h>
 
void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}
 
int partition(int arr[], int low, int high)
{
    int pivot = arr[high];
    int i = (low - 1);
 
    for (int j = low; j <= high - 1; j++) {
        if (arr[j] < 

猜你喜欢

转载自blog.csdn.net/weixin_35756373/article/details/129613154