#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
void sort(int* array, int n) ;
typedef struct list {
int number;
struct list* behind;
} list;
void InitList (list* ptr);
int main() {
int n, i;
int x;
scanf("%d", &n); /*输入数组长度*/
getchar();
scanf("%d", &x); /*输入数组长度*/
getchar();
if (n == 0) { /*判断数组长度是否合理*/
return -1;
}
int array[100] = { 0 }; /*定义数组*/
int* p = array; /*定义指针*/
for (i = 0; i < n; i++) { /*输入n个正整数*/
scanf("%d", array + i);
getchar();
}
//sort(array, n);
list* head = NULL;
list* link = NULL;
int k;
//create list
for (k = 0; k < n; k++) {
list* alloc = (list*)malloc(sizeof(list));
alloc->number = array[k];
alloc->behind = NULL;
if (head == NULL) {
head = alloc;
link = alloc;
} else {
link->behind = alloc;
link = link->behind;
}
}
list* delete = NULL;
list* prev = NULL;
list* last = head;
while (head != NULL && head->number == x) {
delete = head;
head = head->behind;
free(delete);
}
while (last != NULL) {
if (last->number == x) {
delete = last;
prev->behind = last->behind;
last = last->behind;
free(delete);
}
else {
prev = last;
last = last->behind;
}
}
while (head != NULL) {
printf("%d ", head->number);
head = head->behind;
}
// for (i = 0; i < n; i++) {
// printf("%d ", array[i]);
// }
return 0;
}