标签:
晚上又玩了会冒泡法,
void bubbleSort(int* a, int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n-i; j++) {
if (a[j+1] > a[j]) {
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
print(a, n, i);
}
}
void bubbleSort(int* a, int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (a[j] > a[j]) {
int temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
print(a, n, i);
}
}
标签:
原文地址:http://www.cnblogs.com/martinho/p/5838415.html