连表问题
#include <iostream.h>
typedef struct Ring
{
int Code;
Ring * Next;
} A ;
A* Head; //全局变量,头指针
A* Cr() //创建连表
{
A*Ps; A*Pc;
Ps=new A;
cin>>Ps->Code;
Pc=Ps;
Head=NULL;
while(Ps->Code!=0)
{
if(Head=NULL) Head=Ps;
else Pc->Next=Ps;
Pc=Ps;
Ps=new A;
cin>>Ps->Code;
}
Pc->Next=NULL;
delete Ps;
return (Head);
}
void Show(A* head) //展示连表
{
while(head)
{
cout<<head->Code<<endl;
head=head->Next;
}
}
void main()
{
A *P;
P=Cr();
Show(P);
}
大家给我指点以下,究竟那里出问提了,整个程序输不出结果