📄 stack2.h
字号:
class stack{ //定义一个栈,存放表达式的数据
public:
double Vec[100];
int MaxSize;
int top;
public:
stack()
{top=-1;MaxSize=100;}
~stack(){};
void Push(double x);
double Pop();
double GetTop();
void Clear(){top=-1;}
int IsEmpty()
{
if(top==-1)
return 1;
else
return 0;
}
}array;
void stack::Push(double x)
{
if(top==MaxSize-1)
cout<<"overflow!"<<endl;
else
{
top++;
Vec[top]=x;
}
}
double stack::Pop()
{
double temp;
if(top==-1)
cout<<"underflow!"<<endl;
else
{
temp=Vec[top];
top--;
return temp;
}
return -1;
}
double stack::GetTop()
{
if(top==-1)
cout<<"underflow!"<<endl;
else
return Vec[top];
return -1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -