#include <stdio.h>
void exchange(int *p, int len);
int main()
{
int array[10] = {1, 3, 2, 5, 6, 7, 8, 9, 43, 12};
exchange(array, 10);
int c;
for(c = 0; c<10; c++){
printf("%d ",array[c]);
}
return 0;
}
void exchange(int *p, int len)
{
int i, j, temp;
for(i = 0; i < len; i++){
for(j = 0; j < len-i-1; j++){
if(p[j]>p[j+1]){
temp = p[j];
p[j] = p[j+1];
p[j+1] = temp;
}
}
}
}
输出:
1 2 3 5 6 7 8 9 12 43
学了四五年的C语言 连冒泡排序都写不出来 就会一种排序方法 还没搞懂 干个屁的软件开发!