class Demo11
{
public static void main(String[] args)
{
int i, j, temp;
int[] arr = {1, 32, 78, 65, 21, 45};
//选择排序
for(i = 0; i < arr.length - 1; ++i)
{
for(j = i+1; j < arr.length; ++j)
{
if(arr[i] > arr[j])
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
System.out.println("选择");
for(i = 0; i < arr.length; ++i)
{
System.out.print(arr[i] + ",");
}
//冒泡排序
for(i = 0; i < arr.length - 1; ++i)
{
for(j = 0; j < arr.length - i - 1; ++j)
{
if(arr[j] > arr[j+1])
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
System.out.println("冒泡");
for(i = 0; i < arr.length; ++i)
{
System.out.print(arr[i] + ",");
}
}
}