快排
来源:互联网 发布:有约束条件的优化问题 编辑:程序博客网 时间:2024/05/16 18:01
// xiantree.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int Part(int sorce[], int low, int high)
{
int temp = sorce[low];
int inL = low;
int inH = high;
while (inH > inL)
{
while(inH > inL && sorce[inH] >=temp) inH--;//注意要等号!
sorce[inL] = sorce[inH];
while (inH > inL && sorce[inL] <= temp) inL++;
sorce[inH] = sorce[inL];
}
sorce[inL] = temp;
return inL;
}
void QuickSort(int sorce[],int low,int high)
{
int mid;
if (low < high)
{
mid = Part(sorce, low, high);
QuickSort(sorce, low, mid-1);
QuickSort(sorce, mid+1, high);
}
else
{
return;
}
}
int main(int argc, char* argv[])
{
int a[3]={3,2,1};
QuickSort(a,0,2);
for (int i = 0;i<12;i++)
{
printf("%d ",a[i]);
}
printf("\n");
printf("Hello World!\n");
return 0;
}
//
#include "stdafx.h"
int Part(int sorce[], int low, int high)
{
int temp = sorce[low];
int inL = low;
int inH = high;
while (inH > inL)
{
while(inH > inL && sorce[inH] >=temp) inH--;//注意要等号!
sorce[inL] = sorce[inH];
while (inH > inL && sorce[inL] <= temp) inL++;
sorce[inH] = sorce[inL];
}
sorce[inL] = temp;
return inL;
}
void QuickSort(int sorce[],int low,int high)
{
int mid;
if (low < high)
{
mid = Part(sorce, low, high);
QuickSort(sorce, low, mid-1);
QuickSort(sorce, mid+1, high);
}
else
{
return;
}
}
int main(int argc, char* argv[])
{
int a[3]={3,2,1};
QuickSort(a,0,2);
for (int i = 0;i<12;i++)
{
printf("%d ",a[i]);
}
printf("\n");
printf("Hello World!\n");
return 0;
}
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排
- 快排。
- 深入研究 C++中的 STL Deque 容器
- mysql insert的几点操作(DELAYED 、IGNORE、ON DUPLICATE KEY UPDATE )
- 使用java BufferedWriter写信息到文件中带自动换行
- ios UIScrollView 创建多图像分页滚动
- javascript动态指定action多按钮提交同一form
- 快排
- 深入浅出SharePoint—第三方工作流引擎对比
- Jquery Easy UI Databox 用法
- 财务中以dialog的方式配置
- <context-param>与<init-param>的区别与作用含与Spring整合时的文件配置
- java实现的简单词法分析器
- 关于org.hibernate.exception.SQLGrammarException: could not insert:
- scala lift环境搭建(9)
- 动画那点事 UIKit, CoreGraphics