📄 cheku.cpp
字号:
// cheku.cpp: implementation of the cheku class.
//
//////////////////////////////////////////////////////////////////////
#include "cheku.h"
#include <iostream.h>
#include <stdlib.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
cheku::cheku(int size):top(-1),MaxSize(size)
{
S=new int[MaxSize]; //创建存储栈的数组
}
void cheku::ruku(int x)
{
if (top==MaxSize-1) throw "车库满!";
top++; //车库未满,则入库
S[top]=x;
}
int cheku::chuku()
{
int item;
if (top==-1) throw "车库空";
item=S[top--];//等价于item=S[top];top--;
return item;
}
int cheku::Find(int a)
{
for(int i=top;i>=0;i--)
{
if(a==S[i])
return i;
}
return 0;
}
bool cheku::Full()
{
if(top==MaxSize-1)
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -