#include <stdio.h>
#define Max 255
typedef struct
{
int data[Max];
int top;
}stack;
int count=0;
stack init_stack(stack S)
{
S.top=0;
return S;
}
stack push(int n,stack S)
{
S.data[S.top]=n;
S.top++;
return S;
}
stack pop(stack S)
{
S.top--;
return S;
}
int getTop(stack S)
{
return S.data[S.top-1];
}
int Empty(stack S)
{
if(S.top==0) return 1;
else return 0;
}
int Full(stack S)
{
if(S.top==Max) return 1;
else return 0;
}
void display(stack S)
{
int n=S.top;
for(int i=0;i<n;i++)
printf("%d\n",S.data[n-i-1]);
printf("\n");
}
void functionn()
{
stack S;
for(int i=0;i<=15;i++)
{
S=push(i,S);
}
display(S);
for(int i=0;i<=10;i++)
{
S=pop(S);
}
display(S);
}
int main()
{
functionn();
return 0;
}
栈的基本操作 -【C语言】
最新推荐文章于 2024-09-10 09:00:00 发布