【算法】冒泡排序法

/// <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;
}
}
}
}

posted on 2014-08-23 20:41  木屐  阅读(99)  评论(0编辑  收藏  举报

导航