package Every;
public class LianXi {
public static void main(String[] args) {
int[] arr = new int[]{22,33,2,344,4,555,333,21,5,8};
for(int x=0;x<arr.length-1;x++)
{
for(int y=x;y<arr.length-1-x;y++)
{
if(arr[y]>arr[y+1])
{
int temp=arr[y];
arr[y]=arr[y+1];
arr[y+1]=temp;
}
}
}
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]+"]");;
}
}
运行结果:::
[22,2,4,21,5,8,33,333,344,555] |