📄 lstack.h
字号:
// Lstack.h: interface for the Lstack class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_LSTACK_H__29856EE4_C38C_4655_8B02_F85A5332A302__INCLUDED_)
#define AFX_LSTACK_H__29856EE4_C38C_4655_8B02_F85A5332A302__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include"link.h"
class Lstack
{
private:
link* top;
int size;
public:
Lstack(int sz=100){top=NULL;size=0;};
virtual ~Lstack(){clear();}
void clear(){
while(top!=NULL){
link* temp=top;
top=top->next;
size=0;
delete temp;
}
}
bool push(const int& item){
top=new link(item,top);
size++;
return true;
}
bool pop(int& it){
if(size==0)return false;
it=top->element;
link* itemp=top->next;
delete top;
top=itemp;
size--;
return true;
}
bool topvalue(int &it)const{
if(size==0)return false;
it=top->element;
return true;
}
int length()const{return size;}
};
#endif // !defined(AFX_LSTACK_H__29856EE4_C38C_4655_8B02_F85A5332A302__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -