对数组的倒置
void SeqList<DataType>::inversion()
{
int i = 0, j = length - 1;
DataType temp;
while(i < j)
{
temp = data[i];
data[i++] = data[j];
data[j--] = temp;
}
}
对链表的倒置
void SeqList<DataType>::inversion()
{
Node<DataType> * p, * q;
p = first->next;
q = p->next;
while(q != NULL)
{
p = q;
q = q->next;
p->next = first->next;
first->next = p;
}
}