不知道哪里写的有问题,没有error,但是输出结果不对。
Node* head = (Node*)malloc(sizeof(Node));
head->next = *phead;
Node* preNode=head;
Node* currentNode =*phead;
currentNode=preNode->next;
double x;
while(currentNode!=NULL&¤tNode->next!=NULL) {
if (currentNode->data == currentNode->next->data) {
x = currentNode->data;
while (currentNode->next!=NULL&& currentNode->next->data== x) {
currentNode=currentNode->next;
}
preNode->next=currentNode->next;
}
else {
preNode=preNode->next;
currentNode = currentNode->next;
}
}
}