所以我试图从链接列表中删除重复项,而且这段代码不起作用。我会输入单词列表,它会在"删除"之前和之后打印相同的列表。请帮忙
typedef struct node {
char data[50];
struct node *next;
} *list;
void removeDuplicate(list words){
list o = NULL, t = NULL, d = NULL;
o = words;
while(o != NULL && o->next != NULL){
t = o;
while(t->next != NULL){
if(o->data == t->next->data){
d = t->next;
t->next = d->next->next;
free(d);
}
else{
t = t->next;
}
}
o = o->next;
}
}
答案 0 :(得分:1)
你不能<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div id="header">
<h1>THE BODAK</h1>
</div>
<ul>
<li><a href="history.php">Back</a>
</li>
<li><a href="#" class="link" id="link" data-title="Bounties/hape.jpg" data-bio="">Hape Atete</a>
</li>
<li><a href="#" class="link" id="link2" data-title="Bounties/porsi.jpg" data-bio="">Porsi Skastrek</a>
</li>
<li><a href="#" class="link" id="link3" data-title="Bounties/alfrekr.jpg" data-bio="">Alfrekr Reistr</a>
</li>
<li><a href="#" class="link" id="link4" data-title="Bounties/brann.jpg" data-bio="">Brann Pust</a>
</li>
<li><a href="#" class="link" id="link5" data-title="Bounties/alpha.jpg" data-bio="">44A61 Alpha</a>
</li>
<li><a href="#" class="link" id="link6" data-title="Bounties/omega.jpg" data-bio="">Omega 001</a>
</li>
<li><a href="#" class="link" id="link6" data-title="Bounties/bidayatan.jpg" data-bio="">Biayatan88B</a>
</li>
</ul>
<br>
<br>
<br>
<br>
<img src="Bounties/hape.jpg" id="pic" name="pic" alt="bounty" style="width:70%;height:100%;">
<div id="bio">AN ASSIGNED BOUNTY</div>
<br>
,因为它们是指向char数组起始位置的指针,并且总是不同的。尝试使用if(o->data == t->next->data)
。