/*
* 快速排序的队列实现:
* 快速排序的栈的实现。
*/
#include <iostream>
#include <queue>
using namespace std;
#define Size 20
#define Low 0
#define High Size-1
typedef int DataType;
typedef int Position;
void PaintArray(DataType Array[], int lengthOfArray);
void QuickSort(DataType Array[],const int low, const int high);
Position GetPosition(DataType Array[],const int low, const int high);
int main(void)
{
DataType Array[Size] = {
23, 25, 45, 78, 89,
12, 45, 65, 43, 32,
98, 54, 32, 54, 32,
21, 34, 54, 22, 34};
PaintArray(Array, Size);
QuickSort(Array, Low, High);
PaintArray(Array, Size);
return 0;
}
//输出
void PaintArray(DataType Array[], int lengthOfArray)
{
for(int i = 0; i < lengthOfArray; i++)
cout<<Array[i]<<" ";
cout<<endl;
}
void QuickSort(DataType Array[],const int low, const int high)
{
queue<DataType> qu;
Position mid;
if(low < high
快速排序的队列的实现
最新推荐文章于 2024-08-13 09:00:00 发布
本文介绍了如何使用队列来实现快速排序。通过定义队列并进行一系列操作,包括将数组元素分隔并重新组织队列,实现了快速排序算法。在主函数中,先展示原始数组,然后进行排序,最后再次展示排序后的数组。
摘要由CSDN通过智能技术生成