_Ziens_

Ревёрс вдусвязного списка

May 4th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. void reverse(List *list) {
  2.     ListItem *newHead = list->tail, *t;
  3.     for (ListItem *item = list->head; item; item = item->prev) {
  4.         t = item->prev;
  5.         item->prev = item->next;
  6.         item->next = t;
  7.     }
  8.     list->tail = list->head;
  9.     list->head = newHead;
  10. }
Add Comment
Please, Sign In to add comment