public static void MaoPaoSort()
{
int ret = 0;
int[] intArray = { 10,0,20,50,12,32,89,10,21};
for (int i = 0; i < intArray.Length - 1;i++ )
{
for (int j = i + 1; j < intArray.Length ;j++ )
{
if (intArray[j] < intArray[i])
{
ret = intArray[i];
intArray[i] = intArray[j];
intArray[j] = ret;
}
}
}
for (int i = 0; i < intArray.Length;i++ )
{
Console.WriteLine(intArray[i]);
}
}
C# 冒泡排序
最新推荐文章于 2020-11-28 05:49:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)