Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int top = -1;
  5. int blad = 0;
  6.  
  7. struct stos{
  8. int array[100];
  9. int next;
  10.  
  11. };
  12.  
  13. int STACK_EMPTY(){
  14. if(top==0)
  15. return -1;
  16. else
  17. return 1;
  18.  
  19. }
  20.  
  21. void PUSH(struct stos *S,int x){
  22. scanf("%d",&x);
  23. top = top +1;
  24. S->array[top] = x;
  25. S->next = top+1;
  26. }
  27.  
  28.  
  29. void POP(struct stos *S,int x){
  30. if(STACK_EMPTY() == -1){
  31. blad =1;
  32. }else{
  33. top--;
  34. }
  35. }
  36. void END(struct stos *S){
  37. int i;
  38. for(i=0;i<S.next;i++){
  39. printf("%d")
  40. }
  41. }
  42.  
  43.  
  44. int main()
  45. {
  46. struct stos heap;
  47. PUSH(&heap,1);
  48. printf("%d\n",top);
  49. printf("%d\n",heap.next);
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. printf("%d\n",heap.array[0]);
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement