快速排序
来源:互联网 发布:sql server 2008 sp4 编辑:程序博客网 时间:2024/06/05 19:11
int Random(int start,int end)
{
int t;
srand((unsigned int )time(NULL));
while(true)
{
t=rand()%(end+1);
if(t>=start)
return t;
}
}
int findPartition(int aLow,int aHight)
{
char x;
//srand((unsigned int )time(0));
//int randIndex = aLow+rand()%(aHight-aLow);
// int randIndex = Random(aLow,aHight);
// x = temp[randIndex];
// temp[randIndex] = temp[aHight];
// temp[aHight] = x;
int par = temp[aHight];
int i = aLow-1;
for (int j = aLow; j < aHight;++j)
{
if (par >= temp[j])
{
++i;
x =temp[i];
temp[i] = temp[j];
temp[j] = x;
}
}
x =temp[i+1];
temp[i+1] = temp[aHight];
temp[aHight] = x;
return i+1;
}
void quickSort(int aLow,int aLen)
{
if (aLow < aLen)
{
int privote = findPartition(aLow,aLen);
quickSort(aLow,privote-1);
quickSort(privote+1,aLen);
}
}
- 快速排序
- 快速排序
- 快速排序
- 快速排序!
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 代码大全2(读书笔记16)
- JS验证URL
- sql中用CTE实现增加row_number()列
- Linux图形界面中客户端、服务器、窗口管理器之间的关系
- 深刻理解Python中的元类(metaclass)
- 快速排序
- 错误;找不到主类 Version3:TOSWT
- Building a Flexible UI
- 项目5-特殊三位数
- Oracle Buffer Cache 中 Keep Pool 说明
- Android实现推送方式解决方案
- 依赖(耦合)倒转原则
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- 在COM中使用数组参数-SafeArray