- 1
- 0
- 约2.58千字
- 约 3页
- 2020-10-22 发布于广东
- 举报
#includestdio.h
#include Stack.h
#include StackCommonFunction.h
void main()
{
Stack s;
T x;
CreateStack(s,10);
Push(s,10);
Push(s,15);
PrintStack(s);
x=*InputElement();
Push(s,x);
PrintStack(s);
Pop(s);
Pop(s);
if(IsEmpty(s))
printf(Is Empty!\n);
else
printf(Is not Empty!\n);
PrintStack(s);
}
#includestdio.h
#include Stack.h
#include StackCommonFunction.h
T *InputElement()
{
static T a;
scanf(%d,a);
return a;
}
void PrintElement(T x)
{
printf(%d ,x);
}
void PrintStack(Stack s)
{
if(IsEmpty(s))
printf(The Stack is empty!\n);
else
for(;s.Top=0;s.Top--)
PrintElement(s.Element[s.Top]);
1
}
void CreateStack(Stack *s,int maxsize)
{
s-Top=-1;
s-MaxSize=maxsize;
}
BOOL IsEmpty(Stack s)
{
return s.Top0;
}
BOOL IsFull(Stack s)
{
return s.Top=s.MaxSize-1;
}
void Push(Stack *s,T x)
{
if(IsFull(*s))
printf(Overflow!\n);
else
{
s-Top++;
s-Element[s-Top]=x;
}
}
void Pop(Stack *s)
{
if(IsEmpty(*s))
printf(Underflow!\n);
else
s-Top--;
}
void StackTop(Stack s,T *x)
{
if(IsEmpty(s))
printf(Underflow);
else
*x=s.Element[s.Top];
}
#ifndef STACK_H
#define STACK_H
#define MAXSIZE 50
#define FALSE 0
2
#define TRUE 1
typedef int BOOL;
typedef int T;
typedef struct stack
{
int Top,MaxSize;
T Element[MAXSIZE];
} Stack;
#endif
#ifndef STACKCOMMONFUNCTION_H
#define STACKCOMMONFUNCT
您可能关注的文档
- civil rights movement独立运动(整理).doc
- civil rights movement独立运动(整理).pptx
- civil rights movement独立运动(整理)(一).pdf
- cmd命令大全(整理).doc
- cmd命令大全(整理).pptx
- cmd命令大全(整理)(一).pdf
- CNAS基础知识(整理).pptx
- CNAS基础知识(整理)(一).pdf
- COD去除剂说明(整理).pptx
- COD去除剂说明(整理)(一).pdf
- 2025年北京市门头沟区中考一模英语试题.docx
- 2025年北京市门头沟区中考二模英语试题.docx
- 2025年北京市丰台区中考二模英语试题.docx
- 2025年中考英语考前冲刺模拟卷 (北京专用) 解析卷.docx
- 2025年中考英语考前冲刺模拟卷 (北京专用) 原卷.docx
- 2025年肩颈按摩仪行业社媒趋势数据分析.docx
- 2025年人身险行业信用回顾与2026年展望.docx
- 合同法买卖合同培训课件.ppt
- 2025年全球食物系统与SDG研究报告-食物供给、食者健康、生态平衡的整体治理.docx
- 2025下半年四川乐山市川投峨眉铁合金(集团)有限责任公司对考前自测高频考点模拟试题最新.docx
原创力文档

文档评论(0)