Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (scanf("%s", s)) {
- if (!strcmp(s, "push")) {
- scanf("%d", &n);
- push(stack, &r, n);
- printf("ok\n");
- }
- else if (!strcmp(s, "pop")) {
- if (!isEmpty(&r)) {
- printf("%d\n", pop(stack, &r));
- }
- else return printf("error\n"), 0;
- }
- else if (!strcmp(s, "top")) {
- if (!isEmpty(&r)) {
- printf("%d\n", top(stack, &r));
- }
- else return printf("error\n"), 0;
- }
- else if (!strcmp(s, "size")) {
- printf("%d\n", count(&r));
- }
- else if (!strcmp(s, "exit")) {
- return printf("bye\n"), 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement