#include "common.h"
//冒泡排序
template<class Elem>
void BubbleSort(Elem arr[], int nStart, int nEnd,
Compare<Elem>& comp = Lower<Elem>())
{
++nEnd; //使nEnd指向最后一位的末尾
for (int x = nStart; x != nEnd; ++x)
{
for (int y = nEnd - 1; y != x; --y)
{
if (comp(arr[y], arr[y - 1]))
{
swap(arr, y, y - 1);
}
}
}
}
//冒泡排序
template<class Elem>
void BubbleSort(Elem arr[], int nStart, int nEnd,
Compare<Elem>& comp = Lower<Elem>())
{
++nEnd; //使nEnd指向最后一位的末尾
for (int x = nStart; x != nEnd; ++x)
{
for (int y = nEnd - 1; y != x; --y)
{
if (comp(arr[y], arr[y - 1]))
{
swap(arr, y, y - 1);
}
}
}
}