#include<iostream>
using namespace std;
typedef struct ListNode {
int val;
struct ListNode* next;
}ListNode,*List;
void createList(List L, int n) {
ListNode* r = L;
for (int i = 0; i < n; i++) {
ListNode* p=new ListNode;
cin >> p->val;
p->next = NULL;
r->next = p;
r = r->next;
}
}
void printList(List L) {
ListNode* p = L;
while (p) {
cout << p->val<<" ";
p = p->next;
}
}
List deleteSameNode(List L ){
ListNode* cur = L;
if (L == NULL)
return NULL;
while (cur&&cur->next) {
if (cur->val == cur->next->val)
cur->next = cur->next->next;
else
cur = cur->next;
}
return L;
}
int main() {
List L = new ListNode;
L->next = NULL;
int n;
cout << "请输入链表长度:";
cin >> n;
createList(L, n);
printList(deleteSameNode(L->next));
return 0;
}