不同类型的网站,怎么建立公司网站?,企点官网下载,游戏开发需要多少钱?归纳编程学习的感悟#xff0c; 记录奋斗路上的点滴#xff0c; 希望能帮到一样刻苦的你#xff01; 如有不足欢迎指正#xff01; 共同学习交流#xff01; #x1f30e;欢迎各位→点赞 #x1f44d; 收藏⭐ 留言#x1f4dd;既然选择了远方#xff0c;当不负青春…
归纳编程学习的感悟 记录奋斗路上的点滴 希望能帮到一样刻苦的你 如有不足欢迎指正 共同学习交流 欢迎各位→点赞 收藏⭐ 留言既然选择了远方当不负青春砥砺前行 SeqStack.h
#pragma once
#includestdio.h
#includestdlib.h#define MaxSize 100
typedef int DataType;typedef struct
{DataType data[MaxSize];int top;
}SeqStack;void InitSeqStack(SeqStack* S);int StackEmpty(SeqStack S);int GetTop(SeqStack S, DataType* e);int PushStack(SeqStack* S, DataType e);int PopStack(SeqStack* S, DataType* e);int StackLength(SeqStack S);void ClearStack(SeqStack* S);
SeqStack.cpp
#include SeqStack.h#define _CRT_SECURE_NO_WARNINGS 1void InitSeqStack(SeqStack* S)
{S-top -1;
}int StackEmpty(SeqStack S)
{if (S.top -1){return 1;}else{return 0;}
}int GetTop(SeqStack S,DataType *e)
{if (S.top -1){printf(栈已为空\n);return 0;}*e S.data[S.top];return 1;
}int PushStack(SeqStack* S, DataType e)
{if (S-top MaxSize - 1){printf(栈已满不能将元素入栈\n);return 0;}S-top;S-data[S-top] e;return 1;
}int PopStack(SeqStack* S, DataType* e)
{if (S-top -1){printf(栈中已经没有元素不能进行出栈操作\n);return 0;}*e S-data[S-top];S-top--;return 1;
}int StackLength(SeqStack S)
{S.top;return S.top;
}void ClearStack(SeqStack* S)
{S-top -1;
}main.cpp
#define _CRT_SECURE_NO_WARNINGS 1
#includeSeqStack.hint main()
{SeqStack S;int e;InitSeqStack(S);PushStack(S, 10);PushStack(S, 20);printf(%d\n, StackLength(S));GetTop(S, e);printf(%d\n, e);PopStack(S, e);GetTop(S, e);printf(%d\n, e);PopStack(S, e);printf(%d\n, e);if (StackEmpty(S) 1){printf(栈已为空\n);}PushStack(S, 50);GetTop(S, e);printf(%d\n, e);ClearStack(S);if (StackEmpty(S) 1){printf(栈已为空\n);}return 0;
}