- 0
- 0
- 约1.15千字
- 约 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]);;}
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;3
您可能关注的文档
- CIIA公式集(I)(整理)(一).pdf
- civil rights movement独立运动(整理).doc
- civil rights movement独立运动(整理).pptx
- civil rights movement独立运动(整理)(一).pdf
- cmd命令大全(整理).doc
- cmd命令大全(整理).pptx
- cmd命令大全(整理)(一).pdf
- CNAS基础知识(整理).pptx
- CNAS基础知识(整理)(一).pdf
- COD去除剂说明(整理).pptx
- 2025年北京市门头沟区中考一模英语试题.docx
- 2025年北京市门头沟区中考二模英语试题.docx
- 2025年北京市丰台区中考二模英语试题.docx
- 2025年中考英语考前冲刺模拟卷 (北京专用) 解析卷.docx
- 2025年中考英语考前冲刺模拟卷 (北京专用) 原卷.docx
- 2025年肩颈按摩仪行业社媒趋势数据分析.docx
- 2025年人身险行业信用回顾与2026年展望.docx
- 合同法买卖合同培训课件.ppt
- 2025年全球食物系统与SDG研究报告-食物供给、食者健康、生态平衡的整体治理.docx
- 2025下半年四川乐山市川投峨眉铁合金(集团)有限责任公司对考前自测高频考点模拟试题最新.docx
最近下载
- 金田JTE 388系列变频器使用手册.pdf
- 第五章+中国的地理差异+课件-2023-2024学年八年级地理下学期人教版.pptx VIP
- 第五章+中国的地理差异+第1课时+课件-2023-2024学年八年级地理下学期人教版.pptx VIP
- 【地理】中国的地理差异第1课时课件-2025-2026学年人教版地理八年级下册.pptx VIP
- 第五章+中国的地理差异+第1课时课件2022-2023学年人教版地理八年级下册.pptx VIP
- ACI_318-05美国混凝土结构设计规范(中文版).docx VIP
- 东北师范大学2024-2025学年第2学期《线性代数》期末试卷(A卷)及参考答案.docx
- 2025年会考政治江苏真题及答案.doc VIP
- 人教版八年级下册地理 第五章第1课时 中国的地理差异 说课课件.ppt VIP
- 第五章 中国的地理差异 说课课件(26张PPT) 2024-2025学年八年级地理下学期人教版.pptx VIP
原创力文档

文档评论(0)