冒泡排序很简单,在这里就不说明原理了,直接上代码。
void BubbleSort(unsigned long * lstNum, size_t nSize) { unsigned long nTemp; for (unsigned int i = 0; i < nSize; i++) for (unsigned int j = nSize - 1; j > i; j--) { if (lstNum[j] < lstNum[j - 1]) { nTemp = lstNum[j - 1]; lstNum[j - 1] = lstNum[j]; lstNum[j] = nTemp; } } }