Task Description: the data in the Lb table (,) is (, 20) insert the data in La and Lb into Lc sequentially, but initialize at least one data for Lc. Otherwise, the data cannot be inserted. I don't know how to change it and display () or return status results.
# Include <iostream> // include the file using namespace std; # define LIST_INIT_SIZE 100 // initialize the allocation Volume # define LISTINCREMENT 10 // increment the storage space allocation typedef int status; // Type Definition of the storage structure returned function status result code typedef int ElemType; // The Data Element/end point indicates that this is the user-defined data type used by the node typedef struct {ElemType * elem; // The first address of the node's storage space int length; // int listsize of the current length; // The current allocated storage capacity (in sizeof (ElemType)} IntNode; // It is equivalent to defining a node class called IntNode in java status IntList (IntNode & L) {// This Functions are used to construct an empty linear table. Before that, we need to allocate 100 elemtypes of L to it. elem = (ElemType *) malloc (LIST_INIT_SIZE * sizeof (ElemType); // allocate 100 ElemType buckets and assign the addresses to elem if (! L. elem) exit (0); // if no allocation is successful, the storage fails. length = 0; // The length is 0 L. listsize = LIST_INIT_SIZE; // The initial capacity is 100 return true;} status InsertList (IntNode & L, int n) {cout <"Enter data" <endl; for (int I = 0; I <n; I ++) {cin> L. elem [I]; ++ L. length; if (L. length> = L. listsize) {ElemType * newbase; newbase = (ElemType *) realloc (L. elem, (L. listsize + LISTINCREMENT) * sizeof (ElemType); if (! Newbase) exit (0); L. elem = newbase; L. length + = LISTINCREMENT; // This Code indicates that when the length of a linear table is smaller than the maximum allocated space, // you need to allocate a new allocation space of 110 and assign the pointer to newbase} return true ;} status ListLength (IntNode & L) {int answer; for (int I = 0; I <L. length; I ++) {answer ++;} return L. length;} status ListInsert (IntNode & L, int I, ElemType e) {// insert an Eelement before the position I and increase the length of L // with the precondition I, it must be 1 <= I <= L. length + 1 if (I> L. length | I <0) return false; if (L. len Limit> = L. listsize) {ElemType * newbase; newbase = (ElemType *) realloc (L. elem, (L. listsize + LISTINCREMENT) * sizeof (ElemType); if (! Newbase) exit (0); L. elem = newbase; L. length + = LISTINCREMENT; // This Code indicates that when the length of a linear table is smaller than the maximum allocated space, // you need to allocate a new allocation space of 110 and assign the pointer to newbase} ElemType * p = & (L. elem [I-1]); // the specified location for (ElemType * q = & (L. elem [L. length-1]); q> = p; -- q) {* (q + 1) = * (q ); // right shift of the inserted position and subsequent elements} * p = e; ++ L. length; return true;} status GetElem (IntNode & L, int I) {ElemType * p = & (L. elem [I-1]); ElemType e = * p; return e;} status LocateElem (IntNode & L, ElemType e) {ElemType * p = & (L. elem [0]); // The first position for (ElemType * q = & (L. elem [L. length-1]); p <= q; p ++) {if (e = * p) return true;} return false;} status display (IntNode & L, int n) {for (int I = 0; I <= n; I ++) {cout <L. elem [I] <";} return true;} int main () {IntNode La; IntNode Lb; IntNode Lc; IntList (La); IntList (Lb ); intList (Lc); InsertList (Lc, 1); InsertList (La, 4); InsertList (Lb, 7); int I = 1; int j = 1; int k = 0; ElemType e = GetElem (La, 1); while (I <= La. length & j <= Lb. length) {ElemType e1 = GetElem (La, I); ElemType e2 = GetElem (Lb, j); if (e1 <= e2) {ListInsert (Lc, ++ k, e1); ++ I;} else {ListInsert (Lc, ++ k, e2); ++ j ;}} while (I <= La. length) {ElemType e3 = GetElem (La, I ++); ListInsert (Lc, ++ k, e3);} while (j <= Lb. length) {ElemType e4 = GetElem (Lb, j ++); ListInsert (Lc, ++ k, e4) ;}cout <display (Lc, 11) <endl; cout <endl; return 0 ;}