void ReversePrint(Node *head)
{
Node *prev = NULL, *curr = head, *next;
if(head != NULL) {
while(curr != NULL) {
next = curr->next;
curr->next = prev;
prev = curr;
curr = next;
}
head = prev;
while(prev != NULL) {
printf("%d\n", prev->data);
prev = prev->next;
}
}
}
{
Node *prev = NULL, *curr = head, *next;
if(head != NULL) {
while(curr != NULL) {
next = curr->next;
curr->next = prev;
prev = curr;
curr = next;
}
head = prev;
while(prev != NULL) {
printf("%d\n", prev->data);
prev = prev->next;
}
}
}
No comments:
Post a Comment