Language: Java

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node{
  int key;
  struct node *next;
  struct node *prev;
}Node;

Node *nil;

Node *listSearch(int key){
  Node *cur = nil->next;
  while(cur!= nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x= (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next  =x;
  x->prev = nil;
}

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--;
    }
  }
Node *cur = nil->next;
int isf = 0;
while(1){
  if(cur == nil) break;
  if(isf++>0)printf(" ");
  printf("%d", cur->key);
  cur=cur->next;
}
printf("\n");
  return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <stdio.h>
         ^
Main.java:2: error: illegal character: '#'
#include <stdlib.h>
^
Main.java:3: error: illegal character: '#'
#include <string.h>
^
Main.java:6: error: class, interface, enum, or record expected
  struct node *next;
  ^
Main.java:7: error: class, interface, enum, or record expected
  struct node *prev;
  ^
Main.java:8: error: class, interface, enum, or record expected
}Node;
^
Main.java:10: error: class, interface, enum, or record expected
Node *nil;
^
Main.java:12: error: class, interface, enum, or record expected
Node *listSearch(int key){
^
Main.java:14: error: class, interface, enum, or record expected
  while(cur!= nil && cur->key != key){
  ^
Main.java:16: error: class, interface, enum, or record expected
  }
  ^
Main.java:18: error: class, interface, enum, or record expected
}
^
Main.java:22: error: class, interface, enum, or record expected
  nil->next = nil;
  ^
Main.java:23: error: class, interface, enum, or record expected
  nil->prev = nil;
  ^
Main.java:24: error: class, interface, enum, or record expected
}
^
Main.java:28: error: class, interface, enum, or record expected
  t->prev->next = t->next;
  ^
Main.java:29: error: class, interface, enum, or record expected
  t->next->prev = t->prev;
  ^
Main.java:30: error: class, interface, enum, or record expected
  free(t);
  ^
Main.java:31: error: class, interface, enum, or record expected
}
^
Main.java:35: error: class, interface, enum, or record expected
}
^
Main.java:39: error: class, interface, enum, or record expected
}
^
Main.java:43: error: class, interface, enum, or record expected
}
^
Main.java:47: error: class, interface, enum, or record expected
  x->key = key;
  ^
Main.java:48: error: class, interface, enum, or record expected
  x->next = nil->next;
  ^
Main.java:49: error: class, interface, enum, or record expected
  nil->next->prev = x;
  ^
Main.java:50: error: class, interface, enum, or record expected
  nil->next  =x;
  ^
Main.java:51: error: class, interface, enum, or record expected
  x->prev = nil;
  ^
Main.java:52: error: class, interface, enum, or record expected
}
^
Main.java:56: error: unnamed classes are a preview feature and are disabled by default.
  int size = 0;
  ^
  (use --enable-preview to enable unnamed classes)
Main.java:57: error: class, interface, enum, or record expected
  char com[20];
  ^
Main.java:59: error: class, interface, enum, or record expected
  scanf("%d", &n);
  ^
Main.java:60: error: class, interface, enum, or record expected
  init();
  ^
Main.java:62: error: class, interface, enum, or record expected
  for( i = 0; i<n; i++){
  ^
Main.java:62: error: class, interface, enum, or record expected
  for( i = 0; i<n; i++){
              ^
Main.java:62: error: class, interface, enum, or record expected
  for( i = 0; i<n; i++){
                   ^
Main.java:64: error: class, interface, enum, or record expected
    if(com[0] == 'i'){
    ^
Main.java:66: error: class, interface, enum, or record expected
      np++;
      ^
Main.java:67: error: class, interface, enum, or record expected
      size++;
      ^
Main.java:68: error: class, interface, enum, or record expected
    }else if (com[0] == 'd'){
    ^
Main.java:71: error: class, interface, enum, or record expected
        else if(com[6] == 'L')deleteLast();
        ^
Main.java:72: error: class, interface, enum, or record expected
      }else{
      ^
Main.java:74: error: class, interface, enum, or record expected
        nd ++;
        ^
Main.java:75: error: class, interface, enum, or record expected
      }
      ^
Main.java:77: error: class, interface, enum, or record expected
    }
    ^
Main.java:81: error: class, interface, enum, or record expected
while(1){
^
Main.java:83: error: class, interface, enum, or record expected
  if(isf++>0)printf(" ");
  ^
Main.java:84: error: class, interface, enum, or record expected
  printf("%d", cur->key);
  ^
Main.java:85: error: class, interface, enum, or record expected
  cur=cur->next;
  ^
Main.java:86: error: class, interface, enum, or record expected
}
^
Main.java:88: error: class, interface, enum, or record expected
  return 0;
  ^
Main.java:89: error: class, interface, enum, or record expected
}
^
51 errors