fork download
  1. #include <stdio.h>
  2. int *A, stkTop;
  3. int stkFunc (int opcode, int val)
  4. { static int size=2, stkTop=1;
  5. switch (opcode)
  6. { case -1: size = val; break;
  7. case 0: if (stkTop < size) A[++stkTop] = ++val; break;
  8. default: if (stkTop <= size) return A[--stkTop]; }
  9. return 1; }
  10. int main()
  11. { int B[20]; A=B; stkTop = -2;
  12. stkFunc(-1, 6);
  13. stkFunc(0, 3);
  14. stkFunc(0, 8);
  15. printf("%d\n", stkFunc (3, 2) + stkFunc (5, 8)); }
  16.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
4