#define maxsize 栈空间容量
void InOutS(int s[maxsize])
//s是元素为整数的栈本算法进行入栈和退栈操作
{int top=; //top为栈顶指针定义top=时为栈空
for(i=; i<=n; i++) //n个整数序列作处理
{scanf(%d&x); //从键盘读入整数序列
if(x!=) // 读入的整数不等于时入栈
if(top==maxsize){printf(栈满\n);exit();}else s[++top]=x; //x入栈
else //读入的整数等于时退栈
{if(top==){printf(栈空\n);exit();} else printf(出栈元素是%d\ns[top])}}
}//算法结束
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []