struct LNode *insert(struct LNode *head,int x,int i)
{
int j=1;
struct LNode *s,*q;
q=head;
s=(struct LNode *) malloc ( sizeof(struct LNode) );
s->data=x;
if(i==1)
{
s->next=q;
head=s;
}
else
{
while(q->next != NULL)
{
q=q->next;
j++;
}
if(j==i-1)
{
s->next=q->next;
q->next=s;
}
else
printf("error! there is no position\n");
}
return(head);
}
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela