diff --git a/code/ds/BinaryInsertSort.cpp b/code/ds/BinaryInsertSort.cpp index 08e0936..072b88e 100644 --- a/code/ds/BinaryInsertSort.cpp +++ b/code/ds/BinaryInsertSort.cpp @@ -8,7 +8,6 @@ void BinaryInsertSort(ElemType Arr[],int n){ lowIndex=1; // 左侧子表 折半查找起始位置 highIndex=i-1; // 左侧子表 折半查找结束位置 - while(lowIndex<=highIndex){ // 左侧有序子表的中间位置角标 @@ -23,7 +22,8 @@ void BinaryInsertSort(ElemType Arr[],int n){ } } - // 跳出循环需要(lowIndex>heightIndex),说明待插入位置的角标在heightIndex之后,为 heightIndex+1,此时需要将(heightIndex,i)之间的所有元素后移 + // 跳出循环需要(lowIndex>heightIndex), + // 说明待插入位置的角标在heightIndex之后,为 heightIndex+1,此时需要将(heightIndex,i)之间的所有元素后移 for(j=i-1;j>highIndex;--j){ Arr[j+1]=Arr[j] diff --git a/code/ds/BubbleSort.cpp b/code/ds/BubbleSort.cpp index b3040c8..6b30db4 100644 --- a/code/ds/BubbleSort.cpp +++ b/code/ds/BubbleSort.cpp @@ -1,15 +1,11 @@ // 冒泡排序 void BubbleSwapSort(ElemType A[], int n){ - for(i=0;ii;j--){ if(A[j-1].key>A[j].key){ - // 将两个元素A[j-1]、A[j]进行交换,有多种方法 swap(A[j-1],A[j]) // 确认已发生交换 @@ -26,7 +22,6 @@ void BubbleSwapSort(ElemType A[], int n){ /** * 加减法实现两个元素值互换 - * */ void swap(int a, int b){ // 此时a为两值的和 @@ -37,10 +32,8 @@ void swap(int a, int b){ a=a-b; } -/** - * 临时变量实现两个元素值的互换 - * - */ + +// 临时变量实现两个元素值的互换 void swap(int a,int b){ int temp; temp=a; diff --git a/docs/manuscripts/note-map/cn-map.md b/docs/manuscripts/note-map/cn-map.md index 0a0d2af..ff8ab9d 100644 --- a/docs/manuscripts/note-map/cn-map.md +++ b/docs/manuscripts/note-map/cn-map.md @@ -2,11 +2,7 @@ # 计算机网络