麻烦大家给看看 程序有错误,大家帮忙看看哪里错了,谢谢!!!
LinkList CreateList(LinkList &head) //顺序建表
{
head=new Node;
head->next=NULL;
Node *q=head;
int flag=1;
while(flag)
{
int x;
cin>>x;
if(x!=0)
{
Node *p=new Node;
p->data=x;
p->next=NULL;
q->next=p;
q=p;
}
else
flag=0;
}
return head;
}
void Print(LinkList &head)
{
Node *p;
p=head->next;
while(p)
{
cout<data<<" ";
p=p->next;
}
}
int main()
{
LinkList L;
CreateList(L);
Print(L);
return 0;
}