diff --git a/归并排序.cpp b/归并排序.cpp index cee21ff..ff66fd3 100644 --- a/归并排序.cpp +++ b/归并排序.cpp @@ -8,7 +8,7 @@ void print(int a[], int n) { cout << endl; } -//��r[i��m]��r[m +1 ��n]�鲢����������rf[i��n] +//将r[i...m]和r[m+1...n]归并到辅助数组rf[i...n] void Merge(ElemType *r, ElemType *rf, int i, int m, int n) { int j, k; @@ -31,13 +31,13 @@ void MergeSort(ElemType *r, ElemType *rf, int lenght) len = 2 * s; int i = 0; while (i + len < lenght) { - Merge(q, rf, i, i + s - 1, i + len - 1); //�Եȳ��������ӱ��ϲ� + Merge(q, rf, i, i + s - 1, i + len - 1); i = i + len; } if (i + s < lenght) { - Merge(q, rf, i, i + s - 1, lenght - 1); //�Բ��ȳ��������ӱ��ϲ� + Merge(q, rf, i, i + s - 1, lenght - 1); } - tmp = q; q = rf; rf = tmp; //����q,rf���Ա�֤��һ�˹鲢ʱ���Դ�q �鲢��rf + tmp = q; q = rf; rf = tmp; } } @@ -47,7 +47,7 @@ int main() { int b[10]; MergeSort(a, b, 10); print(b, 10); - cout << "�����"; + cout << "结果:"; print(a, 10); }