📄 seqstack.cpp
字号:
#include "seqstack.h"
#include <iostream>
using namespace std;
seqstack::seqstack()
{
top=new stack();
}
seqstack::~seqstack()
{
}
istream& operator >>(istream& in,seqstack& l)
{
cout<<"请输入结点个数"<<endl;
int i;
in>>i;
stack *p=l.gethead();
cout<<"输入第1"<<"个结点data值"<<endl;
in>>p->data;
for(int m=1;m<i;m++)
{
stack *q=new stack();
cout<<"输入第"<<m+1<<"个结点data值"<<endl;
in>>q->data;
p->link=q;
p=q;
}
return in;
}
ostream& operator <<(ostream& out,seqstack& l)
{
stack *p=l.gethead();
int i=1;
while(p!=NULL)
{
out<<'#'<<i<<':'<<p->data<<endl;
i++;
p=p->link;
}
return out;
}
void seqstack::push(char& ch)
{
stack *p=new stack();
p->data=ch;
p->link=top;
top=p;
}
void seqstack::pop(char& ch)
{
ch=top->data;
stack *p=top->link;
delete top;
top=p;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -