package com.wsy;
public class paopao {
public static void main(String[] args) {
int []a={16,20,9,90,23};
for (int i=0;i< a.length;i++) {
System.out.print(a[i]+"\t");
}
System.out.println("");
for (int i=0;i< a.length-1;i++){
for (int j = 0; j < a.length-1-i; j++) {
if (a[j]>a[j+1]){
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for (int i=0;i< a.length;i++) {
System.out.print(a[i]+"\t");
}
}
}
16 20 9 90 23
9 16 20 23 90
进程已结束,退出代码为 0
package com.wsy;
public class paopao {
public static void main(String[] args) {
int []a={16,20,9,90,23};
for (int i=0;i< a.length;i++) {
System.out.print(a[i]+"\t");
}
System.out.println("");
for (int i=0;i< a.length;i++){
for (int j = i; j < a.length; j++) {
if (a[i]>a[j]){
int temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
for (int i=0;i< a.length;i++) {
System.out.print(a[i]+"\t");
}
}
}
16 20 9 90 23
9 16 20 23 90
进程已结束,退出代码为 0