Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
- struct node
- {
- node *prev;
- int x;
- node *next;
- };
- node *ptr = 0, *ptr2 = 0, *ptr3 = 0, *ptr4 = 0, *ptr5 = 0, *ptr6 = 0, *ptr7 = 0;
- int main()
- {
- int t, i, j, k, l, a, b, c, d, y, z, n;
- char ch;
- ptr = (node *)malloc(sizeof(node));
- ptr->x = -1919191;
- ptr->prev = 0;
- ptr->next = 0;
- ptr2 = ptr;
- ptr3 = ptr;
- ptr4 = ptr;
- scanf("%d", &t);
- getchar();
- for (i = 1; i <= t; i++)
- {
- ptr2 = ptr4;
- ch = getchar();
- getchar();
- scanf("%d", &n);
- getchar();
- if (ch == 105)
- {
- printf("List: ");
- ptr->next = (node *)malloc(sizeof(node));
- ptr = ptr->next;
- ptr->x = n;
- ptr->next = 0;
- ptr->prev = ptr3;
- ptr3 = ptr;
- ptr2 = ptr;
- for (; ;)
- {
- b = ptr2->x;
- ptr7 = ptr2->prev;
- if (ptr7->x == -1919191) break;
- a = ptr7->x;
- if (a > b)
- {
- ptr7->x = b;
- ptr2->x = a;
- }
- ptr2 = ptr2->prev;
- }
- ptr2 = ptr4;
- while(true)
- {
- ptr2 = ptr2->next;
- printf("%d ", ptr2->x);
- if (ptr2->next == 0) break;
- }
- putchar(10);
- }
- if (ch == 100)
- {
- d = 0;
- for (; ;)
- {
- ptr2 = ptr2->next;
- if (ptr2->x == n)
- {
- printf("%d Deleted\n", n);
- ptr5 = ptr2->prev;
- ptr6 = ptr5;
- ptr5->next = ptr2->next;
- ptr5 = ptr5->next;
- ptr5->prev = ptr6;
- d = 1;
- break;
- }
- if (ptr2->next == 0) break;
- }
- if (d == 0) printf("%d Not Found\n", n);
- }
- if (ch == 115)
- {
- ptr2 = ptr4, d = 0;
- for (; ;)
- {
- ptr2 = ptr2->next;
- if (ptr2->x == n)
- {
- printf("%d Found\n", n);
- d = 1;
- break;
- }
- if (ptr2->next == 0) break;
- }
- if (d == 0) printf("%d Not Found\n", n);
- }
- }
- return 0x0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement