#include <stdio.h>
void bubbleSort(int *numberPointer,int numbers) {
int i, j,middle=0;
for (i = 0; i < numbers; i++) {
for (j = 0; j < numbers - i-1; j++) {
if (*(numberPointer + j) >*(numberPointer + j + 1)) {
middle = *(numberPointer + j);
*(numberPointer + j) = *(numberPointer + j + 1);
*(numberPointer + j + 1) = middle;
}
}
}
}
void main() {
int sum[10] = { 74,894,24,654,1,12,464,548,56486,545615 };
int i;
bubbleSort(&sum[0], 10);
for (i = 0; i < 10; i++)
printf("%-10d", sum[i]);
system("pause");
}
运行结果:1 12 24 74 464 548 654 894 56486 545615