Language: C

#include<stdio.h>
#include<string.h>
struct node
{  int key;
   node *next,*prev;
};
node *head;
node *listsearch(int key)
{  node *cur=head->next;
   while(cur!=head&&cur->key!=key) 
     cur=cur->next;
   return cur;
}
void init()// 初始化双向链表，即生成空结点为表头，让head.next和head.prev都指向head 
{  head=new node;
   head->next=head=NULL;
   head->prev=head=NULL;
}
void printlist()
{  node *cur=head->next;
   int isf=0;
   while(1)
   {  if(cur==NULL) break;
      else if(isf++>0) printf(" ");
      printf("%d",cur->key);
      cur=cur->next;
   }
   printf("\n");
}
void deletenode(node *t)//删除相应结点 
{  if(t==NULL)  return;//如果t为头结点时不做处理
   t->prev->next=t->next;//t的前一个结点的next指向t的后一个结点 
   t->next->prev=t->prev;//t的后一个结点的prev指向t的前一个结点 
   delete t; 
}
void deletefirst()// 删除头结点next所指向的结点 
{  deletenode(head->next); 
}
void deletelast()// 删除头结点prev 所指向的结点 
{  deletenode(head->prev); 
}
void deletekey(int key)// 删除搜索到的结点 
{  deletenode(listsearch(key));
}
void insert(int key)//新的结点总是在头结点的后面 
{  node *x=new node;
   x->key=key;
   x->next=head->next;
   head->next->prev=x;
   head->next=x;
   x->prev=head;
}
int main()
{  int key,n,i;
   int size=0;
   char com[20];
   int np=0,nd=0;
   scanf("%d",&n);
   init();
   for(i=0;i<n;i++)
   {  scanf("%s%d",&com,&key);
      if(com[0]=='i')
      {  insert(key);
         np++;
         size++;
      }
      else if(com[0]=='d')
      {  if(strlen(com)>6)
         {  if(com[6]=='F')  deletefirst();
            else if(com[6]=='L')  deletelast();
         }
      }
      else
      {  deletekey(key);
         nd++;
      }
      size--;
   }
   printlist();
} 


Compiler output:
main.c:5:4: error: unknown type name 'node'
    5 |    node *next,*prev;
      |    ^~~~
main.c:7:1: error: unknown type name 'node'; use 'struct' keyword to refer to the type
    7 | node *head;
      | ^~~~
      | struct 
main.c:8:1: error: unknown type name 'node'; use 'struct' keyword to refer to the type
    8 | node *listsearch(int key)
      | ^~~~
      | struct 
main.c: In function 'listsearch':
main.c:9:4: error: unknown type name 'node'; use 'struct' keyword to refer to the type
    9 | {  node *cur=head->next;
      |    ^~~~
      |    struct 
main.c:9:18: error: request for member 'next' in something not a structure or union
    9 | {  node *cur=head->next;
      |                  ^~
main.c:10:24: error: request for member 'key' in something not a structure or union
   10 |    while(cur!=head&&cur->key!=key)
      |                        ^~
main.c:11:13: error: request for member 'next' in something not a structure or union
   11 |      cur=cur->next;
      |             ^~
main.c: In function 'init':
main.c:15:9: error: 'new' undeclared (first use in this function)
   15 | {  head=new node;
      |         ^~~
main.c:15:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:12: error: expected ';' before 'node'
   15 | {  head=new node;
      |            ^~~~~
      |            ;
main.c:16:8: error: request for member 'next' in something not a structure or union
   16 |    head->next=head=NULL;
      |        ^~
main.c:17:8: error: request for member 'prev' in something not a structure or union
   17 |    head->prev=head=NULL;
      |        ^~
main.c: In function 'printlist':
main.c:20:4: error: unknown type name 'node'; use 'struct' keyword to refer to the type
   20 | {  node *cur=head->next;
      |    ^~~~
      |    struct 
main.c:20:18: error: request for member 'next' in something not a structure or union
   20 | {  node *cur=head->next;
      |                  ^~
main.c:25:22: error: request for member 'key' in something not a structure or union
   25 |       printf("%d",cur->key);
      |                      ^~
main.c:26:14: error: request for member 'next' in something not a structure or union
   26 |       cur=cur->next;
      |              ^~
main.c: At top level:
main.c:30:17: error: unknown type name 'node'
   30 | void deletenode(node *t)//删除相应结点
      |                 ^~~~
main.c: In function 'deletefirst':
main.c:37:4: error: implicit declaration of function 'deletenode' [-Wimplicit-function-declaration]
   37 | {  deletenode(head->next);
      |    ^~~~~~~~~~
main.c:37:19: error: request for member 'next' in something not a structure or union
   37 | {  deletenode(head->next);
      |                   ^~
main.c: In function 'deletelast':
main.c:40:19: error: request for member 'prev' in something not a structure or union
   40 | {  deletenode(head->prev);
      |                   ^~
main.c: In function 'insert':
main.c:46:4: error: unknown type name 'node'; use 'struct' keyword to refer to the type
   46 | {  node *x=new node;
      |    ^~~~
      |    struct 
main.c:46:12: error: 'new' undeclared (first use in this function)
   46 | {  node *x=new node;
      |            ^~~
main.c:46:16: error: expected ',' or ';' before 'node'
   46 | {  node *x=new node;
      |                ^~~~
main.c:47:5: error: request for member 'key' in something not a structure or union
   47 |    x->key=key;
      |     ^~
main.c:48:5: error: request for member 'next' in something not a structure or union
   48 |    x->next=head->next;
      |     ^~
main.c:48:16: error: request for member 'next' in something not a structure or union
   48 |    x->next=head->next;
      |                ^~
main.c:49:8: error: request for member 'next' in something not a structure or union
   49 |    head->next->prev=x;
      |        ^~
main.c:50:8: error: request for member 'next' in something not a structure or union
   50 |    head->next=x;
      |        ^~
main.c:51:5: error: request for member 'prev' in something not a structure or union
   51 |    x->prev=head;
      |     ^~