1.冒泡排序
int [] inst={22,43,321,51,4546,86,3215,8651,1,158};
int intTmp=0;
int max=0;
for (int i=0;i<inst.length-1;i++)
{
max+=1;
for (int j=0;j<inst.length-i-1;j++)
{
if (inst[j]>inst[j+1])
{
intTmp=inst[j];inst[j]=inst[j+1];inst[j+1]=intTmp;
}
}
int [] inst={22,43,321,51,4546,86,3215,8651,1,158};
int intTmp=0;
int max=0;
for (int i=0;i<inst.length-1;i++)
{
max+=1;
for (int j=0;j<inst.length-i-1;j++)
{
if (inst[j]>inst[j+1])
{
intTmp=inst[j];inst[j]=inst[j+1];inst[j+1]=intTmp;
}
}
}
//select sort
public static void selectSort(int [] arr)
{
for (int i=0;i<arr.length ;i++ )
{
for (int j=i+1;j<arr.length ;j++ )
{
if (arr[i]<arr[j])
{
int tmp=arr[i];arr[i]=arr[j];arr[j]=tmp;
}
}
}
}