seqstack.h
来自「这是一个关于用递推法解决求某一个集合的所有的子集。非常适合初学数据结构的同胞阅读」· C头文件 代码 · 共 77 行
H
77 行
#include"stdio.h"
#include"stdlib.h"
typedef struct
{
DataTypeS stack [MaxStackSize];
int top;
}SeqStack;
void StackInitiate(SeqStack *S)
{
S->top = 0;
}
int StackNotEmpty(SeqStack S)
{
if( S.top <= 0 )
return 0;
else
return 1;
}
int StackPush(SeqStack *S, DataTypeS x)
{
if( S->top >= MaxStackSize )
{
printf("\nThe stack is full!\n");
return 0;
}
else
{
S->stack[S->top] = x;
S->top ++;
return 1;
}
}
int StackPop(SeqStack *S, DataTypeS *x)
{
if( S->top <= 0 )
{
printf("\nThe stack is empty!\n");
return 0;
}
else
{
S->top --;
*x = S->stack[S->top];
return 1;
}
}
int StackTop(SeqStack S, DataTypeS *x)
{
if( S.top <= 0 )
{
printf("The stack is empty!");
return 0;
}
else
{
*x = S.stack[S.top-1];
return 1;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?