数据结构 实验二:(线性表实验-顺序存储)
实验内容:
内容
问题描述:
编制一个能演示将两个有序表合并为一个有序表的程序。
基本要求:
已知递增有序线性表LA和LB,现将LA和LB合并到LC,LC也是递增有序的。
代码:
/*
时间:2021/03/21
作者:瑞雪流年
功能:1.实现将线性表LA=(3,5,8,11) 、 LB=(2,6,8,9,11,15,20)合并到LC,其中LC也是递增有序的。
*/
#include<bits/stdc++.h>
const int MaxSize=100;
using namespace std;
typedef int ElemType;
//声明线性表的顺序存储类型
typedef struct
{
ElemType data[MaxSize]; //存放线性表中的元素
int length; //存放线性表的长度
int *elem;
int len;
int size;
}SqList; //顺序表类型
//建立顺序表
void CreateList(SqList *&A,ElemType c[],int n) //由c中的n个元素建立顺序表
{
int i;
A=(SqList *)malloc(sizeof(SqList