package BubbleSort;
import java.lang.reflect.Array;
import java.util.Arrays;
/**
*冒泡排序:在一个未知数据大小的情况下,将相同数据类型的数看成一组元素(数组)由大至小排布。
* @author JAVA_Arrary
*排序规则解析如下!
*/
//据相同的数看成一组数组,数据类型要相同!
public class bubbleSort_1 {
public static void main(String[] args) {
int []arrary={2,6,8,3,5,12,44,7};
for (int i = 0; i < arrary.length-1; i++) {
for (int j = 0; j < (arrary.length-1)-i; j++) {
if(arrary[j]>arrary[j+1]){
int teamp=arrary[j+1];
arrary[j+1]=arrary[j];
arrary[j]=teamp;
}
}
}
for (int i = arrary.length-1; i >=0; i--) {
System.out.print(arrary[i]+"\t");
}
System.out.println();
for (int arry:arrary) {
System.out.println(arry+"\t");
}
//用java.util.Arrary中的Arrary.sort排序
int [][]arrarys={{2,6},{8,3},{5,12},{44,7}};
for (int i = 0; i < arrarys.length; i++) {
Arrays.sort(arrarys[i]);
System.out.println("排序后的数据:");
for (int j = 0; j < arrarys[i].length; j++) {
System.out.println(arrarys[i][j]);
}
}
}
}