zoukankan      html  css  js  c++  java
  • Quick sort C# code

    public class IntQuickSort
    {
            private static int Split(int[] data,int low,int high)
           {
                 if(data == null) throw new ArgumentException();
                 if(low<0 || high >= data.length) throw new ArgumentOutOfRangeException();

                 int pivot= data[low];
                 while(low<high)
                 {
                        while(low<high && data[high] >= pivot) high--;
                        data[low] = data[high];
                        while(low<high && data[low] <= pivot) low++;
                        data[high] = data[low];
                  }
                  data[low] = pivot;
                  return low;
            }

            //recursion quick sort
            public static void QuickSort(int[] data,int low,int high)
           {
                int pivot= Split(data,low,high);
                QuickSort(data,low,pivot-1);
                QuickSort(data,pivot+1,high);
            }
           
    }

  • 相关阅读:
    关于在UNIcode环境下得TCHAR转string类型以及string转TCHAR
    c++重要知识点
    c语言五子棋
    修改单词首字母大小写
    MFC界面分割以及挂载
    c语言操作文件函数大全
    字符串的分割
    简单售货机代码
    Oracle数据库的查询
    oracle数据库四大语言
  • 原文地址:https://www.cnblogs.com/stone/p/1232343.html
Copyright © 2011-2022 走看看