//数组{5,1,6,4,2,8,9}由小到大排序;
class Komi
{
public static void daxiao(int [] arr)
{
for(int x=0; x<arr.length-1; x++)
{
for(int y=x+1; y<arr.length;y++)
{
if(arr[x]>arr[y])
{
int temp=arr[x];
arr[x]=arr[y];
arr[y]=temp;
}
}
}
}
public static void bianli(int[] arr)
{
System.out.print("[");
for (int x=0;x<arr.length;x++ )
{
if(x!=arr.length-1)
System.out.print(arr[x]+",");
else
System.out.print(arr[x]+"]");
}
}
public static void main(String[] args)
{
int [] arr={5,1,6,4,2,8,9};
daxiao(arr);
System.out.println(arr[6]);
}
} |