#include <stdio.h> #include <stdlib.h> bubbleSort(int *p,int length); int main() { int a[] = {1,3,2,8,5,9,7,6,4,0}; int length = 10; int i; bubbleSort(&a,10); for(i=0;i<length;i++){ printf("%d ",a[i]); } return 0; } bubbleSort(int *p,int length){ int tmp,flag,i,j; for(i=length-1;i>0;i--){ flag = 0; for(j=0 ; j<i; j++){ if( p[j] > p[j+1] ){ tmp = p[j]; p[j] = p[j+1]; p[j+1] = tmp; flag = 1; } } if(flag == 0) break; } }