Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct Node
- {
- Node * next;
- int data;
- };
- unsigned l_size(Node * p)
- {
- unsigned c = 0;
- while (p)
- {
- c++;
- p = p->next;
- }
- return c;
- }
- // Procedura wyświetla zawartość elementów listy
- void l_printl(Node * p)
- {
- unsigned i;
- for (i = 1; p; p = p->next)
- cout << "Element #" << i++ << " data = " << p->data << endl;
- cout << endl;
- }
- void l_push_front(Node * & head, int v)
- {
- Node * p;
- p = new Node;
- p->data = v;
- p->next = head;
- head = p;
- }
- // Procedura usuwa pierwszy element
- void l_pop_front(Node * & head)
- {
- Node * p = head;
- if (p)
- {
- head = p->next;
- delete p;
- }
- }
- int main()
- {
- Node * L = NULL;
- for (int i = 0; i < 10; i++) {
- l_push_front(L, i);
- }
- l_printl(L);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement