[排序]冒泡排序

说明

  1. unsorted[ ] 为未排序数组
  2. length 为未排序数组长度

使用方法

  1. bubble_sort(数组,长度)

模板

void bubble_sort(int[] unsorted,int length)
{
    for (int i = 0; i < length; i++)
        for (int j = i; j < length; j++)
            if (unsorted[i] > unsorted[j])
            {
                int temp = unsorted[i];
                unsorted[i] = unsorted[j];
                unsorted[j] = temp;
            }
}

results matching ""

    No results matching ""