64,654
社区成员
发帖
与我相关
我的任务
分享
//出栈
void PopLinkStack(LinkStack *top,ElemType &x)
{
LinkStack *p;
p=new LinkStack;
if(top->next=='\0')
cout<<"ERROR!"<<endl;
else {
x=top->data;
p=top;
top=top->next;
}
free(p);
}
void main()
{
LinkStack *top;
cout<<"初始化一个链栈"<<endl;
top=InitLinkStack();
cout<<"入栈一个元素:"<<endl;
ElemType x;
cin>>x;
top=PushLinkStack(top,x);
cout<<"出栈"<<endl;
ElemType y;
PopLinkStack(top,y);
cout<<y<<endl;
system("pause");
}