From b8a7bc7ce60bd3fa2a6ddbb601b4bc8e98791ce2 Mon Sep 17 00:00:00 2001 From: pbqa92cj6 <2956318246@qq.com> Date: Sat, 19 Feb 2022 17:13:15 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E5=BD=92=E5=B9=B6=E6=8E=92=E5=BA=8F.c?= =?UTF-8?q?pp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 归并排序.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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); }