Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /////////////////////////////
- struct TT
- {
- int n;
- TT *pNext;
- };
- /////////////////////////////
- struct LL
- {
- TT *pHead;
- TT *pTail;
- int nCounter;
- ////////////////
- void init();
- int push(int a);
- void pop();
- void clear();
- void LLmonitor();
- } L1;
- //////////////////////////////////////////////////////////
- int main()
- {
- L1.init();
- L1.push(2);
- return 0;
- }
- //////////////////////////////////////////////////////////
- void LL::init()
- {
- pHead = 0;
- pTail = 0;
- nCounter = 0;
- }
- //////////////////////////////////////////////////////////
- int LL::push(int a)
- {
- TT *p = (TT*)malloc(sizeof(TT));
- p->n = a;
- if(nCounter == 0) pHead = p;
- else
- {
- pTail->pNext = p;
- }
- nCounter++;
- p->pNext = 0;
- pTail = p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement