Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- ////////////////////////////////////////////////
- struct T{
- int n;
- T* pNext;
- };
- //////////////////////////////////////////////
- class LL{
- public:
- T* pHead;
- T* pTail;
- int count;
- LL(){
- pHead = 0;
- pTail = 0;
- count = 0;
- }
- void add(int incializing)
- {
- T* p = (T*)malloc(sizeof(T));
- if(pHead == 0)
- {
- pTail = pHead = p;
- }
- else
- {
- pTail->pNext = p;
- pTail = p;
- }
- p->n = incializing;
- count++;
- p->pNext = 0;
- }
- void print()
- {
- T* p = pHead;
- while(p)
- {
- printf("%d\n", p->n);
- p = p->pNext;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement