冒泡排序

void swap(int *a,int *b){
	int temp=*a;
	*a=*b;
	*b=temp;
} 
void BubbleSort(int *a,int length){
	for(int i=0;i<length;i++){
		for(int j=0;j<length-i;j++){
			if(a[j]>a[j+1])
				swap(a+j,a+j+1);
		}
	}    
}

  

posted @ 2019-03-21 22:36  赵钱富贵  阅读(87)  评论(0编辑  收藏  举报