/// <summary>
/// 冒泡法排序
/// </summary>
/// <param name="shuzu"></param>
private static void MySort(int[] shuzu)
{
//比较多少轮
for (int i = 0; i < shuzu.Length - 1; i++)
{
//每一轮比较多少次
for(int j=shuzu.Length-1;j>i;j--)
{
if(shuzu[j]>shuzu[j-1])
{
//交换两个元素的位置
shuzu[j] = shuzu[j - 1] + (shuzu[j - 1] = shuzu[j]) * 0;
}
}
}
}
时间: 2024-10-18 11:59:53