public class TestArray{
public static void main (String[] args){
print(args);
paixun(args);
print(args);
}
private static void paixun (String a[]){
int A=0;
int b=0;
int M=-1;
String c[]= new String [1];
for(int i=a.length-1; i>-1; i--){
A =Integer.parseInt(a[i]);
for(int j=i-1; j>-1; j--){
b =Integer.parseInt(a[j]); '依次找出最大的那个
if (A<b)
{ A=b;
M=j;
}
}
if (M!=-1&& M!=i){
c[0]=a[i];
a[i]=a[M]; 依次将找到的最大值重新排放
a[M]=c[0];
}
M=-1;
}
}
private static void print ( String b[]){
int c[]= new int [b.length];
for(int i=0; i<b.length; i++ ){
try {
c[i] =Integer.parseInt(b[i]);
}catch(NumberFormatException x){System.out.print("error1"); System.exit (-1);} //将排好的string数组转int类型
System.out.print(c[i]+" ");
}
System.out.println();
}
}