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