package shuzu;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import java.util.Arrays;
public class MaopaoDemo01 {
public static void main(String[] args) {
int[] a = {92,5,8,555,76,324,990,667};
System.out.println("冒泡排序后");
int sort[] = sort(a);
System.out.println(Arrays.toString(sort));
}
public static int[] sort(int[] array){
int temp = 0;
for (int i = 0; i<array.length-1;i++){
for (int j = 0; j < array.length-1-i; j++) {
if (array[i] < array[j]) {
temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}return array;
}
}
冒泡排序
代码如上,思路如下
![img](C:\Users\yunfe\Pictures\Saved Pictures\Gallery\bubbleSort.gif)