void linkedlist::reverse()
{
element *ptr= head;
element *nextptr= ptr->next;
while(nextptr)
{
element *temp = nextptr->next;
nextptr->next = ptr;
ptr = nextptr;
nextptr = temp;
}
head->next = 0;
head = ptr;
}
Leave a Reply