Advertisement
dllbridge

Untitled

Aug 23rd, 2023
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1.  
  2.  
  3. #include  <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. ////////////////////////////////////////////
  7. struct TT
  8. {
  9.    
  10.    
  11.     int  nData;
  12.     TT  *pNext;
  13. };
  14.  
  15.  
  16.  
  17. ////////////////////////////////////////////
  18. class LL
  19. {
  20.      
  21.    public:
  22.        
  23.     TT  *pHead;
  24.     TT  *pTail;
  25.    
  26.     int nCounter;
  27.     /////////////
  28.     LL()
  29.     {
  30.       pHead    = 0;
  31.       pTail    = 0;
  32.       nCounter = 0;
  33.     }
  34.    
  35.     void push(int n)
  36.     {
  37.        
  38.        TT *p = (TT*)malloc(sizeof(TT) );
  39.        
  40.        if(pHead == 0)                   // Если список пуст
  41.        {
  42.           pHead = p;    
  43.            
  44.        }
  45.        else
  46.        {
  47.           pTail->pNext = p;
  48.            
  49.        }   
  50.         pTail = p;
  51.         nCounter ++;
  52.     }
  53. };
  54.  
  55.  
  56. ////////////////////////////////////////////
  57. int main()                                //
  58. {
  59.  
  60.     LL list_1;
  61.  
  62.     list_1.push(100);
  63.  
  64. }
  65.  
  66.  
  67.  
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement