Advertisement
dllbridge

Untitled

Oct 22nd, 2020
9,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1.  
  2. //  
  3. //  22 October 2020 (14:02)
  4. //  dllbridge@gmail.com                   //
  5. ////////////////////////////////////////////
  6.  
  7.  
  8. #include   <stdio.h>
  9.  
  10.  
  11. #define push(sp, n)     *sp++ = n
  12. #define  pop(sp)      *--sp
  13.  
  14.  
  15. int         stack[1024],                         // Выделяем 4KB  ( 4096 байт памяти или  4 * 1024 ) для нашего стека
  16.       *sp = stack,                                                                     //  Указатель на вершину стека
  17.                 x,                                                                     //           Просто переменная
  18.                 i;                                                                     //          Счётчик для циклов
  19.  
  20.  
  21. ////////////////////////////////////////////
  22. int main()                                //
  23. {  
  24.  
  25.     for(i = 5; i < 25; i ++)  push(sp, i);  
  26.     for(i = 0; i < 20; i ++)
  27.     {    
  28.         x = pop(sp);
  29.    
  30.         printf("x = %d \n", x);
  31.     }  
  32. }
  33.  
  34.  
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement