Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdlib.h>
- #include<stdio.h>
- void push(int x, int *vf, int *st)
- {
- (*vf)++;
- st[*vf] = x;
- }
- int pop(int *vf, int *st)
- {
- (*vf)--;
- return st[(*vf) + 1];
- }
- int stiva_goala(int *vf, int *st)
- {
- if ((*vf) == -1)
- return 0;
- else
- return 1;
- }
- int main()
- {
- int c, n,vf=-1,st[100],i,x;
- printf("n= ");
- scanf("%d", &n);
- do {
- printf("C= ");
- scanf("%d", &c);
- } while ((c < 0) || (c > 7));
- for (i = 0; i < n; i++)
- {
- printf("Elementul cu numarul %d este: ", i + 1);
- scanf("%d", &x);
- if ((x >> c) & 1)
- {
- push(x, &vf, st);
- }
- }
- do {
- printf("%d ",pop(&vf, st));
- } while (stiva_goala(&vf, st) == 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement