#include <stdio.h>
#define Max 50
struct SqList {
int data[Max];
int length;
};
int PrintList(SqList L) {
for (int i = 0; i < L.length;i++) {
printf("%d", L.data[i]);
}
printf("\n");
printf("表长为%d\,", L.length);
printf("\n");
return 0;
}
bool MergeList(SqList a, SqList b, SqList& c) {
if (c.length < a.length + b.length) {
return false;
}
int i = 0, j = 0, k = 0;
while (i < a.length && j < b.length) {
if (a.data[i] <= b.data[j]) {
c.data[k++] = a.data[i++];
}
else {
c.data[k++] = b.data[j++];
}
}
while (i < a.length) {
c.data[k++] = a.data[i++];
}
while (i < b.length) {
c.data[k++] = b.data[j++];
}
c.length = a.length + b.length;
return true;
}