package lanqiao2022;
public class five {
public static void main(String[] args) {
int[] a= {21,25,49,25,16,8};int t;
for(int i=0;i<a.length;i++) {
for(int j=0;j<a.length-1;j++) {
if(a[j]>a[j+1]) {
t=a[j+1];
a[j+1]=a[j];
a[j]=t;
}
}
}
System.out.printf("冒泡:");
for(int i=0;i<a.length;i++) {
System.out.printf(" %d",a[i]);
}
int[] b= {21,25,49,25,16,8};int min;int num;
for(int i=0;i<b.length-1;i++) {
min=b[i];num=i;
for(int j=i+1;j<b.length;j++) {
if(b[j]<min) {
min=b[j];
num=j;
}
}
t=b[i];
b[i]=min;
b[num]=t;
}
System.out.println();
System.out.printf("选择:");
for(int i=0;i<b.length;i++) {
System.out.printf(" %d",b[i]);
}
}
}