冒泡排序
作者:互联网
/**
* TODO 冒泡排序
*
* @author Roy
* @date 2021/3/13 10:08
*/
public class BubbleSort {
public static void main(String[] args) {
int []bb = new int[]{1,23,4325,456,346,2,1,2,3,56,7};
int[] aa = bubbleSort(bb);
for(int c:aa) System.out.println(c);
}
public static int[] bubbleSort(int sortArray[]){
for(int i=0;i<sortArray.length;i++){
for(int j=0;j<sortArray.length-i-1;j++){
if(sortArray[j]<sortArray[j+1]){
int temp = sortArray[j];
sortArray[j] = sortArray[j+1];
sortArray[j+1] = temp;
}
}
}
return sortArray;
}
}
标签:aa,int,冒泡排序,bubbleSort,static,public 来源: https://blog.csdn.net/lyhellogod/article/details/114731647