Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.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 main()
- {
- int n, i, a,st[8],j,aux,vf=-1;
- printf("Dati numarul de numere: ");
- scanf("%d", &n);
- for (i = 0; i < n; i++)
- {
- printf("Dati o noua valoare ");
- scanf("%d", &a);
- for (j = 7; j >= 0; j--)
- {
- aux = (a >> j) & 1;
- printf("%d", aux);
- push(aux, &vf, st);
- }
- printf("\n");
- for (j = 0; j <= 7; j++)
- {
- aux = pop(&vf, st);
- printf("%d", aux);
- }
- printf("\n\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment