您的位置:首页 > 其它

链栈

2009-12-30 20:02 120 查看
//#include<iostream>
//using namespace std;
//class Link
//{
//
// Link *top;
// int data;
// Link *next;
//public:
// Link* InitLink(Link *top);
// void InsertLink(Link * top,int x);
// void DeleteLink(Link *top);
// int Gettop(Link *top);
// bool EmptyLink(Link *top);
//};
//Link *top,link;
//Link *Link::InitLink(Link *top)
//{ link.top=new Link;
// link.top->next=NULL;
// return link.top;
//}
//
//void Link::InsertLink(Link *top, int x)
//{
// Link *s;
// s=new Link;
// s->data=x;
// s->next=top->next;
// top->next=s;
//}
//
//void Link::DeleteLink(Link *top)
//{
// Link *p;
// p=top->next;
// while(p)
// {
// top->next=p->next;
// delete(p);
// }
//}
//
//int Link::Gettop(Link *top)
//{
// if(top->next==NULL)
// return NULL;
// else
// return top->next->data;
//}
//
//bool Link::EmptyLink(Link *top)
//{
// if(top==NULL)
// return true;
// else
// return false;
//}
//void main()
//{
// /* Link link;
// Link *top=NULL;
// int data;
// cout<<"链栈的初始化"<<endl;
// cin>>data;
// link.InitLink(top);
// cout<<"链栈的插入"<<endl;
// cout<<"输入要插入的元素"<<endl;
// cin>>data;
// link.InsertLink(top,2);
// cout<<"链栈的删除"<<endl;
// cout<<"输入要删除的元素"<<endl;
// cin>>data;
// link.DeleteLink(top);
// cout<<"链栈的取栈顶元素"<<endl;
// link.Gettop(top);
// cout<<"链栈的判断"<<endl;
// link.EmptyLink(top);*/
// top = link.InitLink(top);
// link.InsertLink(top,3);
// cout<<link.Gettop(top);
// link.DeleteLink(top);
// cout<<link.EmptyLink(top)<<endl;
//}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: