惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
罗磊的独立博客
The GitHub Blog
The GitHub Blog
V
V2EX
Last Week in AI
Last Week in AI
博客园 - 聂微东
MyScale Blog
MyScale Blog
美团技术团队
L
LangChain Blog
博客园 - Franky
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
S
SegmentFault 最新的问题
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
量子位
小众软件
小众软件
宝玉的分享
宝玉的分享
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
D
Docker
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

博客园 - Forrest Gump

关于LINQ中数据库连接字符串的问题 项目开发经验-ASP.NET项目开发中的异常处理 关于模态窗口(showModalDialog)的专题【收藏】 C#面试题 C# 将数据导出到Excel汇总 关于Assembly.CreateInstance()与Activator.CreateInstance()方法 PowerDesigner概念设计模型(CDM)中的3种实体关系 C#基础概念二十五问 Microsoft .NET Pet Shop 4:将 ASP.NET 1.1 应用程序迁移到 2.0 用Inno Setup制作WEB程序安装包 冒泡法数组排序与 System.Array.Sort()排序性能比较 堆排序 (Heap sort) 合并排序法(Merge Sort) 希尔排序法 关于switch的小技巧 C#中一些很基础但有经常导致错误的一些概念 Enterprise Library Step By Step系列(十六):使用AppSetting Application Block Enterprise Library Step By Step系列(十五):配置应用程序块——设计篇 创建基于消息队列(MSMQ)的异步日志
quick sort
Forrest Gump · 2008-01-28 · via 博客园 - Forrest Gump

 1using System;
 2namespace MyQSort{
 3 public class QSort //可以写成static public class QSort
 4 {
 5  private static int[] toBeSort;
 6  private static void swap(int a,int b){
 7   int c;
 8   c=toBeSort[a];
 9   toBeSort[a]=toBeSort[b];
10   toBeSort[b]=c;
11  }

12  ///<sumary>
13  ///分割函数
14  ///</sumary>

15  private static int Partition(int low,int high){
16   int pivoKey=toBeSort[low];
17   while(low<high){
18    while(low<high && (toBeSort[high] >= pivoKey)) --high;
19    swap(low,high);
20    while(low<high && (toBeSort[low] <= pivoKey))  ++low;
21    swap(low,high);
22   }

23   return low;
24  }

25  private static void QQSort(int low,int high){
26   int pivoLoc;
27   if(low<high){
28    pivoLoc=Partition(low,high);
29    QQSort(low,pivoLoc-1);
30    QQSort(pivoLoc+1,high);
31   }

32  }

33  public static int[] QuickSort(int [] a){
34   toBeSort=a;
35   QQSort(0,toBeSort.Length-1);
36   return toBeSort;
37  }

38
39 }
;
40}

41