Skip to content

Instantly share code, notes, and snippets.

Created March 29, 2021 00:49
What would you like to do?
SequenceList Insert
Status ListInsert_Sq(SqList *L, int i, LElemType_Sq e)
LElemType_Sq *newbase;
LElemType_Sq *p, *q;
if(i<1 || i>(*L).length+1)
return ERROR;
if((*L).length >= (*L).listsize)
newbase = (LElemType_Sq*)realloc((*L).elem, ((*L).listsize+LISTINCREMENT)*sizeof(LElemType_Sq));
(*L).elem = newbase;
(*L).listsize += LISTINCREMENT;
q = &(*L).elem[i-1];
for(p=&(*L).elem[(*L).length-1]; p>=q; --p)
*(p+1) = *p;
*q = e;
return OK;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment