:: 버블 소트
void BubbleSort (int nArray[], int n)
{
bool bFlag = true;
int nFinalPos = 0, nLimit = 0, nBubbleKey = 0;
nLimit = n - 1;
while(bFlag)
{
bFlag = false;
for(int i = 0 ; i < nLimit ; ++i)
{
if(nArray[i] > nArray[i + 1])
{
nBubbleKey = nArray[i];
nArray[i] = nArray[i+1];
nArray[i+1] = nBubbleKey;
bFlag = true;
nFinalPos = i;
}
}
nLimit = nFinalPos;
}
}
:: 퀵소트
void QuickSort(int nArray[], int nSize)
{
if(nSize > 1)
{
int nStandard = nArray[nSize-1];
int i = -1;
int j = nSize-1;
int nTemp = 0;
while(true)
{
while(nArray[++i] < nStandard);
while(nArray[--j] > nStandard);
if(i >= j) break;
nTemp = nArray[i];
nArray[i] = nArray[j];
nArray[j] = nTemp;
}
nTemp = nArray[i];
nArray[i] = nArray[nSize-1];
nArray[nSize-1] = nTemp;
QuickSort(nArray, i);
QuickSort(nArray + i + 1, nSize - i - 1);
}
}