首页 > 编程 > C > 正文

C经典冒泡排序法实现代码

2020-01-26 15:37:01
字体:
来源:转载
供稿:网友
复制代码 代码如下:

void BubleSort(int* siSortArray, int siLen)
{
         bool bSwapped = true;
         do
         {
                   bSwapped= false;
                   for(int i = 0; i < siLen - 1; i++)
                   {
                            if (siSortArray[i] > siSortArray[i+1]) 
                            {
                                     int temp = siSortArray[i];
                                     siSortArray[i]= siSortArray[i + 1];
                                     siSortArray[i+ 1] = temp;
                                     bSwapped= true;
                            }
                   }
         }while(bSwapped);                    
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选