📄 stack.c
字号:
#include <stdio.h>#include "stack.h"#define MAXVAL 100 /* maximum depth of val stack *//* even better, we could make the following two defines "static" and thus hide these data structures from the rest of the sources */int sp = 0; /* next free stack position */int val[MAXVAL]; /* value stack *//* note: "f" is a funny name for a generic int--"i" would be better *//* push: push f onto value stack */void push(int f){ if (sp < MAXVAL) val[sp++] = f; else printf("error: stack full, can't push %d\n", f);}/* pop: pop and return top value from stack */int pop(void){ if (sp > 0) return val[--sp]; else{ printf("error: stack empty\n"); return 0; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -