【求助】删除链表中符合条件的所有结点!
程序代码:
Polynomil *Remove(Polynomil *head) { int expon; Polynomil *pointer=head->next,*pt; printf("请输入你所要删除的项的指数:\n"); scanf("%d",&expon); if(expon==pointer->expon)//删除第一个结点 { head->next=pointer->next; free(pointer); printf("删除成功!\n"); } else { while(pointer) { pt=pointer; pointer=pointer->next; if(pointer->expon==expon) { pt->next=pointer->next; free(pointer); pointer=pt;//这里是想把前驱结点赋给pointer,然后下一次循环从这个结点开始,直到表尾!但好像行不通 } } } return head; }