fork download
  1. #include <stdio.h>
  2.  
  3. void que(StackType *s1, StackType *s2)
  4. {
  5. int i,n;
  6. n = s1->top;
  7. for (i = n; i > -1; i--)
  8. {
  9. push(s2, pop(s1));
  10. }
  11. }
  12.  
  13. int Out(StackType *s1,StackType *s2)
  14. {
  15. int num;
  16. if (is_empty(s2))
  17. {
  18. que(s1, s2);
  19. num = pop(s2);
  20. return num;
  21. }
  22. else
  23. {
  24. num = pop(s2);
  25. return num;
  26. }
  27. }
  28.  
  29. int main(void)
  30. {
  31. StackType s1, s2;
  32.  
  33. init_stack(&s1);
  34. init_stack(&s2);
  35.  
  36.  
  37. push(&s1, 10);
  38. push(&s1, 20);
  39.  
  40. Out(&s1, &s2);
  41. printf("%d", Out(&s1,&s2));
  42.  
  43.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:3:10: error: unknown type name ‘StackType’
 void que(StackType *s1, StackType *s2)
          ^~~~~~~~~
prog.c:3:25: error: unknown type name ‘StackType’
 void que(StackType *s1, StackType *s2)
                         ^~~~~~~~~
prog.c:13:9: error: unknown type name ‘StackType’
 int Out(StackType *s1,StackType *s2)
         ^~~~~~~~~
prog.c:13:23: error: unknown type name ‘StackType’
 int Out(StackType *s1,StackType *s2)
                       ^~~~~~~~~
prog.c: In function ‘main’:
prog.c:31:2: error: unknown type name ‘StackType’
  StackType s1, s2;
  ^~~~~~~~~
prog.c:33:2: warning: implicit declaration of function ‘init_stack’ [-Wimplicit-function-declaration]
  init_stack(&s1);
  ^~~~~~~~~~
prog.c:37:2: warning: implicit declaration of function ‘push’ [-Wimplicit-function-declaration]
  push(&s1, 10);
  ^~~~
prog.c:40:2: warning: implicit declaration of function ‘Out’ [-Wimplicit-function-declaration]
  Out(&s1, &s2);
  ^~~
prog.c:43:2: error: expected declaration or statement at end of input
  getchar();
  ^~~~~~~
stdout
Standard output is empty