# Include <iostream> using namespace STD; # define list_init_size 100 // initialize the allocation Volume # define listincrement 10 // increment the storage space allocation typedef int status; typedef int elemtype; typedef struct {elemtype * ELEM; // The base address of the bucket int length; // The current length int listsize; // The current allocated storage capacity (in sizeof (elemtype )} sqlist; Status initlist_sq (sqlist & L) {L. ELEM = (elemtype *) malloc (list_init_size * sizeof (elemtype); If (! L. ELEM) Exit (1); // storage allocation failed L. length = 0; // The length of the empty table is 0l. listsize = list_init_size; // return true for the initial storage capacity;} status listinsert_sq (sqlist & L, int I, elemtype E) {// Insert a new element E before position I in the ordered linear table L. The valid value of // I is 1 <= I <= listlength_sq (l) + 1 if (I <1 | I> L. length + 1) return false; // The I value is invalid if (L. length> = L. listsize) // The current bucket is full. {elemtype * newbase = (elemtype *) realloc (L. ELEM, (L. listsize + listincrement) * sizeof (elemtype); If (! Newbase) Exit (1); // storage allocation failed L. ELEM = newbase; // new base address L. listsize + = listincrement; // increase storage capacity} elemtype * q = & (L. ELEM [I-1]); // Q is the insert position for (elemtype * P = & (L. ELEM [L. length-1]); P> = Q; -- p) * (p + 1) = * P; // right shift of the inserted position and elements after insertion * q = E; // insert e ++ L. length; // increase the table length by 1 elemtype L = * q; // return the return l;} int main () {sqlist l referred to in Pointer Q with a custom variable; initlist_sq (l); elemtype S = listinsert_sq (L, 1,1234); cout <S <Endl; return 0 ;}