顺序栈实验
来源:互联网 发布:1688一键传淘宝 编辑:程序博客网 时间:2024/05/17 02:06
#include <iostream>
using namespace std;
#define Stack_Size 200
typedef struct sqStack
{
char *elem;
int top;
int stackSize;
}sqStack;
void initStack_Sq(sqStack &S)
{
S.elem=new char[Stack_Size];
S.top=-1;
S.stackSize=Stack_Size;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void push(sqStack &S,char x)
{
if(S.top==Stack_Size-1)
cout<<"Stack Overflow!";
S.elem[++S.top]=x;
}
char pop(sqStack &S)
{
char x;
if(S.top==-1)
cout<<"Stack Empty!";
x=S.elem[S.top--];
return x;
}
void main()
{
sqStack S;
creatStack_Sq(S,5);
push(S,'a');
cout<<pop(S)<<endl;
destroyStack_Sq(S);
}
using namespace std;
#define Stack_Size 200
typedef struct sqStack
{
char *elem;
int top;
int stackSize;
}sqStack;
void initStack_Sq(sqStack &S)
{
S.elem=new char[Stack_Size];
S.top=-1;
S.stackSize=Stack_Size;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void push(sqStack &S,char x)
{
if(S.top==Stack_Size-1)
cout<<"Stack Overflow!";
S.elem[++S.top]=x;
}
char pop(sqStack &S)
{
char x;
if(S.top==-1)
cout<<"Stack Empty!";
x=S.elem[S.top--];
return x;
}
void main()
{
sqStack S;
creatStack_Sq(S,5);
push(S,'a');
cout<<pop(S)<<endl;
destroyStack_Sq(S);
}
0 0
- 顺序栈验证实验
- 《数据结构》实验【顺序栈】
- 顺序栈实验
- 实验三 顺序栈
- 实验三、顺序栈
- 实验三顺序栈
- 实验之顺序栈
- 实验四 顺序栈
- 实验四顺序栈
- 顺序栈的验证实验
- 实验三之顺序栈
- 实验3.1 顺序栈&链栈
- 实验三:顺序栈和链队列验证实验
- 实验三(1) 顺序栈的验证实验
- 实验四:顺序栈和链栈
- 实验三 顺序栈和链栈
- 实验三、顺序栈和链栈
- 顺序栈基本运算(实验题3.1)
- c++ boost 中的 各种 转换
- 第11周项目5.1 该年第几天
- Spring MVC不要在@Service bean中保存状态
- iOS 8.0 毛玻璃效果利用UIVisualEffectView快速实现
- jPlayer使用指南
- 顺序栈实验
- linux 进程
- 如何进入保护模式
- 386对存储器的保护与栈段初始化
- 数据备份
- 怎么在myeclipse中配置tomcat
- .\OUT\ANO_FLY.axf: Error: L6411E: No compatible library exists with a definition of startup symbol _
- 笔记----从MBR到OS到application
- linux编程之ipc