Advertisement
AdrianMadajewski

Untitled

Nov 6th, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. typedef int Bool;
  3. #define MAX 100
  4. int Top = MAX, Stack[MAX];
  5. void push(int e) {
  6. Stack[‐‐Top] = e;
  7. return;
  8. }
  9. int pop() {
  10. return Stack[Top++];
  11. }
  12. Bool empty() {
  13. return Top == MAX;
  14. }
  15. int main(void) {
  16. int n, i, x;
  17. scanf("%d", &n);
  18. for (i = 0; i < n; i++) {
  19.     scanf("%d", &x);
  20.     push(x);
  21. }
  22. for (i‐‐; i >= 0; i‐‐) {
  23.     printf("%d", pop());
  24. }
  25. printf("\n");
  26. printf("Empty:%d", empty());
  27. printf("\n");
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement