#include <stdio.h>
#include<stdlib.h>
typedef struct
{
int base;
int top;
int stacksize;
}sqstack;
int a[100];
void push(sqstack*p)//入栈
{
if(p->top==100)
return;
int e;
printf("enter number\n");
scanf("%d",&e);
p->top++;
a[p->top]=e;
}
void thetop(sqstack s)//查看栈顶元素
{
printf("the top number is %d\n",a[s.top]);
}
void outstack(sqstack*p)//出栈
{
if(p->top==-1)
{
printf("stack empty\n");
return;
}
int e =a[p->top];
printf("%d is out of the stack\n",e);
p->top--;
}
int main() {
sqstack s;
s.base=0;
s.top=-1;
for (int i=0;i<5;i++) {
push(&s);
}
thetop(s);
outstack(&s);
return 0;
}