/************************************** Problem id : SDUT OJ 2178 User name : Silence-Debug Result : Accepted Take Memory : 316K Take Time : 0MS Submit Time : 2013-05-31 21:05:15 **************************************/ # include# include struct node { int date; struct node *next; } ; struct node *creat(int n) { struct node *head, *tail, *p; head = (struct node *)malloc(sizeof(struct node)); head -> next = NULL; tail = head; for(int i = 0; i < n; i++) { p = (struct node *)malloc(sizeof(struct node)); scanf("%d", &p -> date); p -> next = NULL; tail -> next = p; tail = p; } return head; } void Delete(struct node *&head, int n) { struct node *p, *q, *t, *tail; p = head -> next; while(p) { q = p->next; t = p; while(q) { tail = q; if (p -> date == q -> date) { n--; t -> next = q -> next; q = q -> next; free(tail); } else { q = q->next; t = t->next; } } p = p -> next; } } void sortline(struct node *&head, int n) { struct node *p, *q; while(n--) { p = head -> next; q = p -> next; while(p -> next) { if(p -> date > q -> date) { int t = p -> date; p -> date = q -> date; q -> date = t; } p = p -> next; q = q -> next; } } } void output(struct node *head) { struct node *r = head; while(r -> next -> next != NULL) { printf("%d ", r -> next -> date); r = r -> next; } printf("%d\n", r -> next -> date); } int main(void) { int n; while(~scanf("%d", &n)) { struct node *head; head = creat(n); Delete(head, n); sortline(head, n); output(head); } return 0; }