Advertisement
ahmad_zizo

STACK

Apr 15th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1.  
  2. typedef struct
  3. {
  4. int top;
  5. int items[100];
  6. } Stack;
  7. void initialize(Stack *s)
  8. {
  9. s->top=0;
  10. }
  11. void push(Stack *s,int value)
  12. {
  13. s->items[s->top++]=value;
  14. }
  15. int pop(Stack *s)
  16. {
  17. return s->items[--s->top];
  18. }
  19. int isfull(Stack *s)
  20. {
  21. return s->top<100?0:1 ;
  22. }
  23. int isempty(Stack *s)
  24. {
  25. return s->top==0?1:0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement