Created
April 15, 2015 03:27
-
-
Save songpu2015617/767122161cdf0f583ddc to your computer and use it in GitHub Desktop.
cc150 2.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void duplicate_list(node *head){ | |
if(head==NULL) return; | |
node *p, *q, *c=head; | |
while(c){ | |
p=c; q=c->next; | |
int d = c->data; | |
while(q){ | |
if(q->data==d){ | |
node *t = q; | |
p->next = q->next; | |
q = p->next; | |
delete t; | |
} | |
else{ | |
p = q; q = q->next; | |
} | |
} | |
c = c->next; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment