Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. while (scanf("%s", s)) {
  2. if (!strcmp(s, "push")) {
  3. scanf("%d", &n);
  4. push(stack, &r, n);
  5. printf("ok\n");
  6. }
  7. else if (!strcmp(s, "pop")) {
  8. if (!isEmpty(&r)) {
  9. printf("%d\n", pop(stack, &r));
  10. }
  11. else return printf("error\n"), 0;
  12. }
  13. else if (!strcmp(s, "top")) {
  14. if (!isEmpty(&r)) {
  15. printf("%d\n", top(stack, &r));
  16. }
  17. else return printf("error\n"), 0;
  18. }
  19. else if (!strcmp(s, "size")) {
  20. printf("%d\n", count(&r));
  21. }
  22. else if (!strcmp(s, "exit")) {
  23. return printf("bye\n"), 0;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement