?? symbol_instr_stack.h
字號(hào):
#include<stdio.h>
#include<stdlib.h>
#define MAX 20
typedef struct{
char stack[MAX];
int top;
}symbol_instr;
//初始化棧
void init_stack(symbol_instr *p)
{
if( !p)
printf("\n初始化符號(hào)棧出錯(cuò)!\n");
p->top = -1;
}
//壓棧
void push(symbol_instr *p,char x)
{
if(p->top < MAX-1)
{
p->top++;
p->stack[p->top] = x;
}
else printf("\n符號(hào)棧溢出!\n");
}
//彈棧
char pop(symbol_instr *p)
{
char x;
if(p->top != -1)
{
x = p->stack[p->top];
p->top--;
return x;
}
else
{
printf("\n符號(hào)棧1空!\n");
return 0;
}
}
//取棧頂元素
char get_top(symbol_instr *p)
{
char x;
if(p->top != -1)
{
x = p->stack[p->top];
return x;
}
else
{
printf("\n符號(hào)棧2空!\n");
return 0;
}
}
//自棧底到棧頂遍歷棧元素
void out_stack1(symbol_instr *p)
{
int i;
if(p->top <0)
printf("\n符號(hào)棧3空!\n");
for(i=0; i<=p->top;i++)
{
printf("%c",p->stack[i]);
}
}
//自棧頂?shù)綏5妆闅v棧元素
void out_stack2(symbol_instr *p)
{
int i;
if(p->top <0)
printf("\n符號(hào)棧4空!\n");
for( i=p->top;i>=0;i--)
{
printf("%c",p->stack[i]);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -