SNode * Reverse(SNode * h)
{
SNode * next = NULL;
while(h!=NULL)
{
SNode * t = h;
h = h ->next;
t->next = next;
next = t;
}
return next;
}
int main()
{
SNode * h = new SNode(10);
SNode * t = h;
t->next = new SNode(20);
t = t->next;
t->next = new SNode(30);
t = t->next;
t->next = new SNode(40);
t = t->next;
t->next = new SNode(50);
t = t->next;
t->next =0;
t = h;
while(t!=NULL)
{
cout<<t->data<<endl;
t = t->next;
}
h = Reverse(h);
t = h;
while(t!=NULL)
{
cout<<t->data<<endl;
t = t->next;
}
return 0;
}