void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur-> next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
Monday, September 1, 2008
Reverse a Linked-listed
Posted by Nanya at 12:31 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment