1. The order table of the element value:
BOOL Getelem (sqlist *l, int i, elemtype &e) //Find a data element value in a linear table
{
if (I < 1 | | | i > L-> length)
re Turn false; returns false
E = L-> data[i-1] When a parameter error occurs; Takes the element value return
true; Returns True if element is successfully found
}
2. A single linked list of the value of the element:
BOOL Getelem (linklist *l, int i, elemtype &e) //Find a data element value in a linear table
{
int j = 0;
linklist *p = L; P point to head node, J set to 0 (that is, header node ordinal 0) while
(J < i && P!= NULL) //Find the first node
{ J
+ +; p = P-> next;
}
if (p = = NULL) //does not exist the first Data node, returns 0 return
false;
else //existence of the first Data node, returns 1
{ e = P->;
return true;
}
3. The value of the double linked list:
BOOL Getelem (dlinklist *l, int i, elemtype &e) //Find a data element value in a linear table
{
int j = 0;
Dlinklist *p = L;
while (J < i && P!= NULL)
{
j + +;
p = P-> next;
}
if (p = = NULL) return
false;
else
{
e = P-> data;
return true;
}
4. Cyclic single linked list of the value of the element:
BOOL Getelem (linklist *l,int i, elemtype &e) //Find the element
{
Int j = 0 of the specified position;
Linklist *p;
if (l-> next!= L) //single linked list is not an empty table
{
if (i = = 1)
{
e = L =-> next-> data;
return true;
}
Else //i is not 1 o'clock
{
p = L-> next;
while (J < i-1 && P!= L)
{
j + +;
p = P-> next;
}
if (p = = L) return
false;
else
{
e = P-> data;
return true;
}
}
else //empty table returns false return
false;
}
5. The value of the cyclic double linked list:
BOOL Getelem (dlinklist *l, int i, elemtype &e) //Find a data element value in a linear table
{
int j = 0;
Dlinklist *p;
if (l-> next!= L) //Double linked list is not empty table
{
if (i = = 1)
{
e = L =-> next-> data;
return true;
}
Else //i is not 1 o'clock
{
p = l-> Next;
while (J < i-1 && P!= L)
{
j + +;
p = P-> next;
}
if (p = = L) return
false;
else
{
e = P-> data;
return true;
}
}
else //Double linked list is empty table return
false;
}
6. Stack top element in sequential stack:
BOOL GetTop (Sqstack *s, elemtype &e) //Fetch stack top element
{
if (s-> tops = 1) //Stack is empty, that is, stack under overflow
return false;
E = s-> data[s-> top]; The element that takes the top pointer element of the stack return
true;
}
7. The top element of the chain stack:
BOOL GetTop (Listack *s, elemtype &e)//Fetch stack top element
{
if (s-> next = null)/stack empty condition return
false;
E = s-> next-> data;
return true;
}
8. Sequence queue of the team element value:
BOOL Dequeue (Sqqueue *&q, elemtype &e) //out team
{
if (q-> front = q-> rear)/ team empty overflow
ret Urn false;
Q-> front = (q-> front + 1)% MaxSize;
E = q-> data[q-> front];
return true;
}
9. The evaluation of the sequential string:
Sqstring SubStr (sqstring s,int i,int j)
{
sqstring str;
int k;
str.length = 0;
if (I <= 0 | | i > S.length | | J < 0 | | i + j-1 > s.length) return
str; Returns an empty string for
(k = I-1 K < i + j-1; k++) //Will s.data[i when the parameter is incorrect. I+J] copied to str
str.data[k-i + 1] = s.data[k];
Str.length = j;
return str;