static void BubbleSort(int[] array)
{
int n=array.Length-1;
for(int i=0;i<n;i++)
{
int flag=0;
for(int j=0;j<n-i-1;j++)
{
if(array[j]>array[j+1])
{
flag=1;
int temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
if(flag==0)
break;
}
}
来源:https://www.cnblogs.com/LZHOO97/p/12052384.html