Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 10
- int stack[N];
- int wybor=0;
- int temp;
- int pop(int top)
- {
- if (top=-1)
- printf ("Stos jest pusty");
- else
- {
- printf (" Pop element: %d", stack[top]);
- }
- }
- int push(int top)
- {
- if (top==9)
- printf ("\n\n Stos jest pelny");
- else
- {
- printf ("\n\n Wpisz wartosc: ");
- scanf ("%d",&temp);
- stack[++top]=temp;
- }
- }
- void list()
- {
- }
- int main ()
- {
- int top=-1;
- while (wybor!=4)
- {
- printf ("\n===========================");
- printf ("\n\n Operacje na stosach\n");
- printf ("\n 1. Pop ");
- printf ("\n 2. Push ");
- printf ("\n 3. List ");
- printf ("\n 4. Exit ");
- printf ("\n Wybierz operacje ... ");
- scanf ("%d", &wybor);
- switch (wybor)
- {
- case 1: pop(top);
- top--;
- break;
- case 2: push(top);
- top++;
- break;
- case 3: list();
- break;
- default : printf ("Zly wybor ziomeczku");
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement