class MaoPao
{
public static void main(String[] args)
{
//输入一个数组;
int[]arr={25,24,12,76,101,96,28};
daYin(arr);
paiXu(arr);
daYin(arr);
}
//冒泡排序;
public static void pai(int arr[])
{
for (int x=0;x<arr.length ;x++ )
{
for (int y=0;y<arr.length-x-1;y++ )
{
if (arr[y]>arr[y+1])
{
int temp=arr[y];
arr[y]=arr[y+1];
arr[y+1]=temp;
}
}
}
}
//打印数组;
public static void daYin(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.println(arr[x]+"]");
}
}
}
|
|