C++冒泡排序
void BubbleSort(int datas[], int len)
{
int tem;
bool isSorted = false;
for (int i = len - 1; isSorted == false && i >= 1; --i) {
isSorted = true;
for (int j = 0; j < i; ++j) {
if (datas[j] > datas[j + 1]) {
isSorted = false;
tem = datas[j];
datas[j] = datas[j + 1];
datas[j + 1] = tem;
}
}
}
for (int k = 0; k < len; ++k) {
std::cout << datas[k] << " " ;
}
std::cout << std::endl;
}