題目來源:力扣
**總結:利用count計算有多少個結點在利用i使指針移動到要被刪除的前一個結點 **
typedef struct list{
int val;
struct list *pnext;
}NODE,*PNODE;
PNODE sort(PNODE pHead,int n){
int count=0,i=0;
PNODE p=pHead->pnext,s=pHead;
while(p!=NULL){
p=p->pnext;
count++;
}
while(i!=count-n){
s=s->pnext;
i++;
}
s->pnext=s->pnext->pnext;
return pHead;
}