Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #include <math.h>
- struct node
- {
- int x;
- node *ptr;
- };
- node *ptr2, *ptr3;
- int main()
- {
- int t, i, j, k, l, a, b, c, d, y, z, n;
- char ch;
- ptr2 = 0, ptr3 = 0;
- ptr2 = (node *)malloc(sizeof(node));
- ptr2->ptr = 0;
- ptr3 = ptr2;
- ptr2->x = 10;
- scanf("%d", &t);
- getchar();
- for (i = 1; i <= t; i++)
- {
- ch = getchar();
- if (ch == 100)
- {
- if (ptr3->ptr == 0) puts("Queue Empty");
- else
- {
- printf("%d\n", ptr3->x);
- ptr3 = ptr3->ptr;
- getchar();
- }
- }
- else
- {
- scanf("%d", &d);
- ptr2->ptr = (node *)malloc(sizeof(node));
- ptr2->x = d;
- ptr2 = ptr2->ptr;
- ptr2->ptr = 0;
- getchar();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement