中国铁道建设出版
else { pend->next=p ; pend=p ; }
cout<<"请输入数据(为零表示结束输入):" ;
cin>>a;
}
if(head) pend->next=0 ;
return head ;
}
node * invert(node *head)
{
node *p,*q;
p=head->next;
if(p!=NULL)
{
head->next=NULL;
do
{
q=p->next;
p->next=head;
head=p;
p=q;;
}while(p!=NULL);
}
return head;
}
void print(node *head )
{
if(head==0) { cout<<" 链表为空!\n" ; return ; }
node *p=head ;
cout<<"链表上各个结点的值为:\n";
while(p!=0)
{
cout <<p-> data<<'\t' ;
p=p->next ;
}
}
void release(node *head )