冒泡排序:两两之间进行比较,把大的移到后面,每轮比较之后之后一个就是最大的
#include<stdio.h>
#include<assert.h>
#include<stdlib.h.h>
//从头向尾遍历
//相邻两数进行比较
//将最大数(相对)沉入尾部(相对)
void BubbleSort1(int *arr,int sz){
int i = 0;
int j = 0;
assert(arr);
for
(i=0;i<sz-1;i++){
for
(j=0;j<sz-i-1;j++){
if
(arr[j]>arr[j+1]){
int tmp = arr[j];
arr[j] = arr[j+1];