冒泡排序 int temp ; int array[10] = {9,8,7,6,5,4,3,2}; for (int i = 0; i < 8; i ++) { for (int j = i+1; j < 8; j ++) { if (array[i] > array[j]) { temp = a ...
冒泡排序
int temp ;
int array[10] = {9,8,7,6,5,4,3,2};
for (int i = 0; i < 8; i ++) {
for (int j = i+1; j < 8; j ++) {
if (array[i] > array[j]) {
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
for (int i = 0; i < 8; i ++) {
printf("%d\n",array[i]);
}