lstack.h
来自「利用数据结构中的算法 在VC环境下编写十进制转八进制」· C头文件 代码 · 共 52 行
H
52 行
// 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 + =
减小字号Ctrl + -
显示快捷键?