Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int st[100];
- int vf = 0;
- int push(int x)
- {
- return st[++vf] = x;
- }
- int pop(void)
- {
- return st[vf--];
- }
- void afisare()
- {
- int i;
- for (i = 1; i <= vf; i++)
- {
- printf("%d ", st[i]);
- }
- printf("\n");
- }
- int main()
- {
- int x;
- printf("dati elementul: "); scanf("%d", &x);
- push(x);
- while (vf)
- {
- if (st[vf] > 11)
- {
- st[vf] = pop() - 1;
- }
- else
- {
- push(st[vf] + 2);
- }
- afisare();
- }
- printf("%d", st[0]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment