int Delete(struct Node *p, int index){
Node *q;
int x=-1 , i;
if(index < 1 || index >count(p))
return -1;
if(index==1){
x=first->data;
q=first;
first=first->next;
delete q;
return x;
}
else{
for(i=0; i<index-1 && p; i++){
q=p;
p=p->next;
}
q->next=p->next;
x=p->data;
delete p;
return x;
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter