📄 stack.h
字号:
typedef struct Node1
{
char ch;
struct Node1 *Next;
}Optr,*LinkOptr;//运算符栈
typedef struct Node
{
int num;
struct Node *Next;
}Opnd,*LinkOpnd;//运算数栈
void InitStack(LinkOptr *S)
{
(*S)=(LinkOptr)malloc(sizeof(Optr));
(*S)->Next=NULL;
}//初始化运算符栈
void InitStack(LinkOpnd *S)
{
(*S)=(LinkOpnd)malloc(sizeof(Opnd));
(*S)->Next=NULL;
}//初始化运算数栈
int PushOptr(LinkOptr pr,char ch1)
{
LinkOptr temp;
temp=(LinkOptr)malloc(sizeof(Optr));
temp->ch=ch1;
temp->Next=pr->Next;
pr->Next=temp;
return true;
}//插入运算符到运算符栈
int PushOpnd(LinkOpnd pn,int num1)
{
LinkOpnd temp;
temp=(LinkOpnd)malloc(sizeof(Opnd));
temp->num=num1;
temp->Next=pn->Next;
pn->Next=temp;
return true;
}//插入运算数到运算数栈
char PopOptr(LinkOptr S)
{
if(S->Next==NULL)
return true;
LinkOptr temp;
temp=S->Next;
S->Next=temp->Next;
return temp->ch;
}//删除运算符栈的栈顶元素
int PopOpnd(LinkOpnd S)
{
if(S->Next==NULL)
return true;
LinkOpnd temp;
temp=S->Next;
S->Next=temp->Next;
return temp->num;
}//删除运算数栈的栈顶元素
char GetTop1(LinkOptr S)
{
return S->Next->ch;
}//返回运算符栈的栈顶元素
int GetTop2(LinkOpnd S)
{
return S->Next->num;
}//返回运算数栈的栈顶元素
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -