请问我这个代码(快排,c++)哪里错了


#include <bits/stdc++.h>
using namespace std;
int a[15] = {8,3,6,3,6,9,4,2,4,7,4,7,9,6,3};
bool pan()
{
    for(int i = 0;i <= 13;i++)
    {
        if(a[i] > a[i+1])
        {
            return 0;
        }
    }
    return 1;
}
void ssort(int shou,int wei)
{
    if(pan()) return;
    int l = shou,r = wei,x = a[1];
    for(int i = shou;i <= wei;i++)
    {
        if(a[i] <= x)
        {
            a[l] = a[i];
            l++;
        }
        if(a[i] > x)
        {
            a[r] = a[i];
            r--;
        }
    }
    ssort(shou,shou+(wei-shou)/2-1);
    ssort(shou+(wei-shou)/2,wei);
}
int main()
{
    ssort(0,14);
    for(int i = 0;i <= 14;i++)
    {
        cout << a[i] << ' ';
    }
    return 0;
}

如有帮助,请采纳

快排自己写函数很烦 又很慢

c++的库中自带快排函数sort
让我帮你百度一下 | Let Me Baidu That For You https://btfy.vercel.app/?q=Qysrc29ydOeahOeUqOazlQ==