Language: C

#include <stdio.h>
#include <ctype.h>
#include <string.h>
 
typedef struct _node {
  int key;
  struct _node *next;
  struct _node *prev;
} NODE, *PNODE;
 
PNODE root;
 
void init(void) {
  root = malloc(sizeof(NODE));
  root->next = root;
  root->prev = root;
}
 
void insert(key) {
  PNODE t = malloc(sizeof(NODE));
  t->key = key;
  t->next = root->next;
  t->prev = root;
  root->next->prev = t;
  root->next = t;
}
 
void deleteNode(PNODE node) {
  if (node == root) {
    return;
  }
  node->next->prev = node->prev;
  node->prev->next = node->next;
  free(node);
}
 
void delete(key) {
  PNODE cur = root->next;
  while (cur != root) {
    if (cur->key == key) {
      deleteNode(cur);
      return;
    }
    cur = cur->next;
  }
}
 
void deleteFirst(void) {
  deleteNode(root->next);
}
 
void deleteLast(void) {
  deleteNode(root->prev);
}
 
void printNodes(void) {
  PNODE cur = root->next;
  while (1) {
    printf("%d", cur->key);
    cur = cur->next;
    if (cur != root) {
      putchar(' ');
    } else {
      break;
    }
  }
  putchar('\n');
}
 
void release(void) {
  PNODE tmp, cur = root->next;
  while (cur != root) {
    tmp = cur;
    cur = cur->next;
    deleteNode(tmp);
  }
  free(root);
} 
 
int main(void) {
  char cmd[100];
  int n, i, f;
  int key;
 
  init(); 
 
  scanf("%d", &n);
 
  f = 0;
  while (scanf("%s", cmd) > 0) {
    if (cmd[0] == 'i') {
      f = 1;
    } else if (cmd[0] == 'd') {
      switch (cmd[6]) {
      case '\0':
    f = 2;
    break;
      case 'F':
    deleteFirst();
    break;
      case 'L':
    deleteLast();
    break;
      }
    } else {
      key = atoi(cmd);
      if (f == 1) {
    insert(key);
      } else if (f == 2) {
    delete(key);
      }
    }
  }
 
  printNodes();
 
  release();
 
  return 0;
}
Compile Error Logs:
You are not authorized to see the message.

???????????????
Judge: 10/10 	C 	CPU: 00.27 sec 	Memory: 31852 KB 	Length: 1732 B 	2016-07-11 23:25 	2016-07-11 23:25
???????????±?????????????????????
Case # 	Verdict 	CPU Time 	Memory 	In 	Out 	Case Name
Case #1: 	: Accepted 	00.00 sec 	600 KB 	88 B 	2 B 	01.in
Case #2: 	: Accepted 	00.00 sec 	600 KB 	203 B 	10 B 	02.in
Case #3: 	: Accepted 	00.00 sec 	600 KB 	375 B 	10 B 	03.in
Case #4: 	: Accepted 	00.00 sec 	600 KB 	105 B 	23 B 	04.in
Case #5: 	: Accepted 	00.00 sec 	600 KB 	643 B 	58 B 	05.in
Case #6: 	: Accepted 	00.00 sec 	600 KB 	52 B 	2 B 	06.in
Case #7: 	: Accepted 	00.00 sec 	596 KB 	1058 B 	110 B 	07.in
Case #8: 	: Accepted 	00.00 sec 	596 KB 	1031 B 	116 B 	08.in
Case #9: 	: Accepted 	00.21 sec 	604 KB 	22392494 B 	5 B 	09.in
Case #10: 	: Accepted 	00.27 sec 	31852 KB 	25527813 B 	1288799 B 	10.in
< prev | 	1 	/ 	10 	| next > 	  		 : Accepted        00.00 sec        600 KB
 
Judge Input #1 ( in1.txt | 88 B) 		Judge Output #1 ( out1.txt | 2 B)

9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast

		

1

Comments
 
 ??\????????§??????
 
Categories
 
 
Free Tags
 
 

Compiler output:
main.c: In function 'init':
main.c:14:10: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   14 |   root = malloc(sizeof(NODE));
      |          ^~~~~~
main.c:4:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    3 | #include <string.h>
  +++ |+#include <stdlib.h>
    4 | 
main.c:14:10: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   14 |   root = malloc(sizeof(NODE));
      |          ^~~~~~
main.c:14:10: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c: In function 'insert':
main.c:19:6: error: type of 'key' defaults to 'int' [-Wimplicit-int]
   19 | void insert(key) {
      |      ^~~~~~
main.c:20:13: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   20 |   PNODE t = malloc(sizeof(NODE));
      |             ^~~~~~
main.c:20:13: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c: In function 'deleteNode':
main.c:34:3: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   34 |   free(node);
      |   ^~~~
main.c:34:3: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:34:3: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:34:3: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c: In function 'delete':
main.c:37:6: error: type of 'key' defaults to 'int' [-Wimplicit-int]
   37 | void delete(key) {
      |      ^~~~~~
main.c: In function 'release':
main.c:77:3: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
   77 |   free(root);
      |   ^~~~
main.c:77:3: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c: In function 'main':
main.c:106:13: error: implicit declaration of function 'atoi' [-Wimplicit-function-declaration]
  106 |       key = atoi(cmd);
      |             ^~~~
main.c: At top level:
main.c:121:1: error: unknown type name 'Compile'
  121 | Compile Error Logs:
      | ^~~~~~~
main.c:121:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
  121 | Compile Error Logs:
      |               ^~~~
main.c:126:12: error: stray '\302' in program
  126 | ???????????<U+00B1>?????????????????????
      |            ^~~~~~~~
main.c:127:6: error: stray '#' in program
  127 | Case #  Verdict         CPU Time        Memory  In      Out     Case Name
      |      ^
main.c:128:6: error: stray '#' in program
  128 | Case #1:        : Accepted      00.00 sec       600 KB  88 B    2 B     01.in
      |      ^
main.c:128:73: error: invalid suffix "in" on floating constant
  128 | Case #1:        : Accepted      00.00 sec       600 KB  88 B    2 B     01.in
      |                                                                         ^~~~~
main.c:129:6: error: stray '#' in program
  129 | Case #2:        : Accepted      00.00 sec       600 KB  203 B   10 B    02.in
      |      ^
main.c:129:73: error: invalid suffix "in" on floating constant
  129 | Case #2:        : Accepted      00.00 sec       600 KB  203 B   10 B    02.in
      |                                                                         ^~~~~
main.c:130:6: error: stray '#' in program
  130 | Case #3:        : Accepted      00.00 sec       600 KB  375 B   10 B    03.in
      |      ^
main.c:130:73: error: invalid suffix "in" on floating constant
  130 | Case #3:        : Accepted      00.00 sec       600 KB  375 B   10 B    03.in
      |                                                                         ^~~~~
main.c:131:6: error: stray '#' in program
  131 | Case #4:        : Accepted      00.00 sec       600 KB  105 B   23 B    04.in
      |      ^
main.c:131:73: error: invalid suffix "in" on floating constant
  131 | Case #4:        : Accepted      00.00 sec       600 KB  105 B   23 B    04.in
      |                                                                         ^~~~~
main.c:132:6: error: stray '#' in program
  132 | Case #5:        : Accepted      00.00 sec       600 KB  643 B   58 B    05.in
      |      ^
main.c:132:73: error: invalid suffix "in" on floating constant
  132 | Case #5:        : Accepted      00.00 sec       600 KB  643 B   58 B    05.in
      |                                                                         ^~~~~
main.c:133:6: error: stray '#' in program
  133 | Case #6:        : Accepted      00.00 sec       600 KB  52 B    2 B     06.in
      |      ^
main.c:133:73: error: invalid suffix "in" on floating constant
  133 | Case #6:        : Accepted      00.00 sec       600 KB  52 B    2 B     06.in
      |                                                                         ^~~~~
main.c:134:6: error: stray '#' in program
  134 | Case #7:        : Accepted      00.00 sec       596 KB  1058 B  110 B   07.in
      |      ^
main.c:134:73: error: invalid suffix "in" on floating constant
  134 | Case #7:        : Accepted      00.00 sec       596 KB  1058 B  110 B   07.in
      |                                                                         ^~~~~
main.c:135:6: error: stray '#' in program
  135 | Case #8:        : Accepted      00.00 sec       596 KB  1031 B  116 B   08.in
      |      ^
main.c:135:73: error: invalid suffix "in" on floating constant
  135 | Case #8:        : Accepted      00.00 sec       596 KB  1031 B  116 B   08.in
      |                                                                         ^~~~~
main.c:136:6: error: stray '#' in program
  136 | Case #9:        : Accepted      00.21 sec       604 KB  22392494 B      5 B     09.in
      |      ^
main.c:136:81: error: invalid suffix "in" on floating constant
  136 | Case #9:        : Accepted      00.21 sec       604 KB  22392494 B      5 B     09.in
      |                                                                                 ^~~~~
main.c:137:6: error: stray '#' in program
  137 | Case #10:       : Accepted      00.27 sec       31852 KB        25527813 B      1288799 B       10.in
      |      ^
main.c:137:97: error: invalid suffix "in" on floating constant
  137 | Case #10:       : Accepted      00.27 sec       31852 KB        25527813 B      1288799 B       10.in
      |                                                                                                 ^~~~~
main.c:140:13: error: stray '#' in program
  140 | Judge Input #1 ( in1.txt | 88 B)                Judge Output #1 ( out1.txt | 2 B)
      |             ^
main.c:140:62: error: stray '#' in program
  140 | Judge Input #1 ( in1.txt | 88 B)                Judge Output #1 ( out1.txt | 2 B)
      |                                                              ^
main.c:159:4: error: stray '\' in program
  159 |  ??\????????§??????
      |    ^
main.c:159:13: error: stray '\302' in program
  159 |  ??\????????<U+00A7>??????
      |             ^~~~~~~~