#include <stdio.h>
#include <stdlib.h>
typedef struct LNode *PtrToLNode;
struct LNode {
int Data;
PtrToLNode Next;
};
void Merge(int A[], int TmpArr[], int Left, int Right, int RightEnd)
{
int Len, i, ALen, LeftEnd;
ALen = RightEnd - Left + 1, Len = Left, LeftEnd = Right - 1;
while (Left <= LeftEnd && Right <= RightEnd) {
if (A[Left] < A[Right]) {
TmpArr[Len++] = A[Left++];
} else {
TmpArr[Len++] = A[Right++];
}
}
while (Left <= LeftEnd) {
TmpArr[Len++] = A[Left++];
}
while (Right <= RightEnd) {
TmpArr[Len++] = A[Right++];
}
for (i = 0; i < ALen; i++, RightEnd--
归并排序(数组、链表)
最新推荐文章于 2021-08-17 21:16:17 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)