冒泡排序:
/**
* @author Jay
* @date 2020/7/13 10:12
* 交换排序
* @Description:冒泡排序
*/
public class bubbleSort {
//中心思想,把每次比较大的数往后搬运,每趟最后会得到这一趟最大的数在末尾
public int[] BubbleSort(int[] a) {
for (int i =1; i<a.length; ++i) {
for (int j = 0; j<a.length-i ; ++j) {
if (a[j]<a[j+1]){
int temp= a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
return a;
}
}