关于快排

“`

“`void quicksort(int a[], int left, int right)
{
if (left >= right)
{
return;
}
int c = left;
int b = right;
int spot = a[left];
while (c < b)
{
while (b > c&&a[b] >= spot)//一定要注意=这个符号!!!
{
b–;
}
a[c] = a[b];
while (c < b&&a[c] <=spot)//一定要注意=这个符号!!!
{
c++;
}
a[b] = a[c];
}
a[c] = spot;
quicksort(a, left, c - 1);
quicksort(a, c + 1,right);
}

全部评论

相关推荐

06-27 15:15
长安大学 Java
哈哈哈,你是老六:这种就是培训机构骗钱的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务