📜  优化的冒泡排序 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:46.043000             🧑  作者: Mango

代码示例1
void bubbleSort(int *arr, int n)
{
    for(int i=0; iarray[j+1])
          {
            flag = true;
             int temp = array[j+1];
             array[j+1] = array[j];
             array[j] = temp;
          }
       }
      // No Swapping happened, array is sorted
      if(!flag){
         return;
      }
   }
}