int Insert(
struct ListNode* head,
int i,
char x)
{
struct ListNode *p=head,*s;
int j=
1;
while(p!=NULL&&j<i-
1)
{
p =p->next ;
j++;
}
if(j!=i-
1)
{
printf(
"插入位置不合适\n");
return 0;
}
if((s=(
struct ListNode *)
malloc(
sizeof(
struct ListNode)))==NULL)
return 0;
s->data =x;
s->next =p->next ;
p->next =s;
return 1;
}
int main()
{
struct ListNode *q,*p;
q=CreateList();
Insert(q,
3,
'x');
while(q)
{
printf(
"%c",q->data );
p=q->next;
free(q);
q=p;
}
printf(
"\n");
return 0;
}