?? stack.h
字號(hào):
#include <stdlib.h>
#include <stdio.h>
//出錯(cuò)控制函數(shù)
void Error(char * message)
{
fprintf(stderr, "Error: %s\n",message);
exit(1);
}
// 定義棧類型
#define StackSize 100
typedef char Datatype;
typedef struct{
Datatype data[StackSize];
int Top;
} SeqStack;
void InitStack( SeqStack *S)
{
//初始化(置空棧)
S->Top=-1;
}
int EmptyStack(SeqStack *S)
{ //判棧空
return S->Top == -1;
}
int FullStack (SeqStack *S)
{ // 判棧滿
return S->Top==StackSize-1;
}
void Push (SeqStack *S , Datatype x)
{ //進(jìn)棧
if(FullStack(S))
Error("Stack overflow");
S->data[++S->Top]=x;
}
Datatype Pop(SeqStack *S)
{ // 出棧(退棧)
if (EmptyStack( S) )
Error( "Stack underflow");
return S->data[S->Top--];
}
//取棧頂元素(略)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -