//选择
public static int[] SelectSort(int [] a){
for (int i = 0; i < a.length-1; i++) {
for (int j = i+1; j < a.length; j++) {
if(a[i]>a[j]){
int temp;
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
return a;
}
//冒泡
public static int[] BubbleSort(int[] a){
for (int i = 0;i<a.length-1;i++) {
for (int j = 0;j<a.length-1;j++) {
if(a[j]>a[j+1]){
int temp;
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
return a;
}
冒泡排序,选择排序
最新推荐文章于 2023-10-03 11:53:44 发布