C#快速排序代码
2018-07-20 来源:open-open
private static int Partition (int[] list, int i, int j)
{
int Key = list [i];
while (i < j)
{
//j to the left scan
while (list [j] >= Key && i < j)
j--;
if(i< j)
list [i++] = list [j];
//i to the right scan
while (list [i] <= Key && i < j)
i++;
IF (i < j)
list [j--] = list[i];
}
list [i] = Key;
return i;
}
public static void QuickSort (int[] list, int low, int high)
{
if(low < high - 1)
{
int Key = Partition (list, low, high);
QuickSort (list, low, Key - 1);
QuickSort (list, Key + 1, high);
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:php准确校验邮箱地址是否存在
下一篇: JAVA 中文转拼音
最新资讯
热门推荐