Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "list.h"
- #include <iostream>
- #include <fstream>
- List::List()
- {
- top = 0;
- this->Reset();
- }
- void List::Reset()
- {
- marker = top;
- pred = top;
- }
- void List::Move()
- {
- if (!this->EoList())
- {
- if (marker == pred)
- marker = marker->next;
- else
- {
- marker = marker->next;
- pred = pred->next;
- }
- }
- }
- bool List::EoList()
- {
- return marker == 0;
- }
- void List::Add(int a)
- {
- node* q;
- if (top == marker)
- {
- q = new node;
- q->data = a;
- q->next = marker;
- top = q;
- pred = q;
- }
- else
- {
- q = new node;
- q->data = a;
- pred->next = q;
- q->next = marker;
- pred = pred->next;
- }
- }
- void List::Del()
- {
- node* q;
- if (marker != 0)
- {
- if (top == marker)
- {
- top = top->next;
- marker = top->next;
- q = pred;
- delete q;
- pred = top;
- }
- else
- {
- marker = marker->next;
- q = pred->next;
- pred->next = marker;
- delete q;
- }
- }
- }
- void List::Show()
- {
- node* q = top;
- while (q != 0)
- {
- std::cout << q->data << " ";
- q = q->next;
- }
- }
Add Comment
Please, Sign In to add comment