quicksortalgorithm.h

来自「实现了对文本文件的huffman编码与解码过程」· C头文件 代码 · 共 54 行

H
54
字号
#include <iostream>
using namespace std;



void QuickSortAlg(float a[], int front, int end)
{
	int newfront = front;
	int newend = end;
	int i = newfront;

	while(end!=front)
	{		
		if(front == i)
		{
			if(a[i]>a[end])
			{
				swap(a[i], a[end]);
				front++;
				i = end;
			}
			else
			{
				end--;
			}
		}
		else
		{
			if(a[i]<a[front])
			{
				swap(a[i], a[front]);
				end--;
				i = front;

			}
			else
			{
				front++;
			}
		}
	}

	if(newfront != front)
	{
		QuickSortAlg(a, newfront, front-1);
	}
	if( newend != front)
	{
		QuickSortAlg(a, front+1, newend);
	}		
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?