Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- void del_mid(node *h);
- typedef struct Node
- {
- int info;
- struct Node *pre, *next;
- }node;
- void del_mid(struct node *h)
- {
- node *ptr; int count=0, count2=0;
- ptr=h;
- do
- {
- count++;
- ptr=ptr->next;
- }
- while(ptr->next!=NULL);
- ptr=h;
- while(count2!=(count/2))
- {
- ptr=ptr->next;
- }
- ptr->next=ptr->next->next;
- ptr->next->pre=ptr;
- do
- {
- printf("%d ", h->info);
- }
- while(ptr->next!=NULL);
- }
- int main() {
- node *ptr, *h; int i;
- h=(node*)malloc(sizeof(node));
- h->pre=NULL;
- ptr=h;
- for(i=0;i<5;i++)
- {
- ptr->next=(node*)malloc(sizeof(node));
- scanf("%d", &(ptr->info));
- ptr->next->pre=ptr;
- }
- del_mid(node *h);
- return(0);
- }
Add Comment
Please, Sign In to add comment