?? stack.cpp
字號:
// Stack.cpp: implementation of the Stack class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TONFA.h"
#include "Stack.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Stack::Stack()
{
vec=new int[SIZE];
maxsize=SIZE;
top=-1;
}
Stack::~Stack()
{
delete [] vec;
}
void Stack::Push(int state)
{
if(top==maxsize-1)
AfxMessageBox("Overflow");
else
{
top++;
vec[top]=state;
}
}
int Stack::Pop()
{
int temp;
if(top==-1)
{
AfxMessageBox("underflow");
return 0;
}
else
{
temp=vec[top];
top--;
return temp;
}
}
int Stack::GetTop()
{
if(top==-1)
{
AfxMessageBox("underflow");
return 0;
}
else
return vec[top];
}
void Stack::Clear()
{
top=-1;
}
int Stack::IsEmpty()
{
if(top==-1)
return 1;
else
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -