Unverified Commit e337888e authored by XTh3G4p's avatar XTh3G4p Committed by GitHub
Browse files

增加冒泡排序起始索引的说明

parent bb7aa155
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -26,11 +26,12 @@ $$
C++ 代码:

```cpp
// 假设数组的大小是n+1,冒泡排序从数组下标1开始
void bubble_sort(int *a, int n) {
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = 0; i < n - 1; ++i) {
    for (int i = 1; i < n; ++i) {
      if (a[i] > a[i + 1]) {
        flag = true;
        int t = a[i];