Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Убрать из списка первый элемент и вернуть его
- ListItem* RemoveHead(ListItem*& list) {
- ListItem* old_head = list;
- list = list->next;
- return old_head;
- }
- // Добавить элемент в голову списка
- void AddToHead(ListItem*& list, ListItem* item) {
- item->next = list;
- list = item;
- }
- // Перевернуть список
- void ReverseList(ListItem*& list) {
- ListItem* reversed_list = 0;
- while (list != 0) {
- ListItem* current_item = RemoveHead(list);
- AddToHead(reversed_list, current_item);
- }
- list = reversed_list;
- }
Advertisement
Add Comment
Please, Sign In to add comment