Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define ROSSO "\x1b[31m"
- #define VERDE "\x1b[32m"
- #define GIALLO "\x1b[33m"
- #define BLU "\x1b[34m"
- #define MAGENTA "\x1b[35m"
- #define CIANO "\x1b[36m"
- #define RESET "\x1b[0m"
- #define MAX 5
- int top, stato;
- void push (int stack[], int item)
- { if (top == (MAX-1))
- stato = 0;
- else
- { stato = 1;
- ++top;
- stack [top] = item;
- }
- }
- int pop (int stack[])
- {
- int ret;
- if (top == -1)
- { ret = 0;
- stato = 0;
- }
- else
- { stato = 1;
- ret = stack [top];
- --top;
- }
- return ret;
- }
- void display (int stack[])
- { int i;
- printf ("\nLo stack è: ");
- if (top == -1)
- printf ("vuoto");
- else
- { for (i=top; i>=0; --i)
- printf ("\n--------\n|%3d |\n--------",stack[i]);
- }
- printf ("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement