#include
#include
define null 0
typedef char ElemType; /* 字符型数据*/
typedef struct LNode
{
ElemType data;
struct LNode *next;
}LNode, *LinkList;
void InsertList(LinkList &L,ElemType x,int i)
{
int j=1;
struct LNode *s,*q;
s=(struct LNode *)malloc(sizeof(struct LNode));
s->data=x;
q=L;
if(i==1)
{
s->next=q;
L=s;
}
else
{
while(j<i-1&&q->next!=null)
{
q=q->next;
j++;
}
if(j==i-1)
{
s->next=q->next; q->next=s;
}
else
cout<<"位置参数不正确!"<<endl;
}
}
提问:为什么从头到尾都是只通过改变p指针的地址?