資源簡介
數據結構實驗
代碼片段和文件信息
#include
#include
#include
?using?namespace?std;
?const?char?oper[7]?=?{?‘+‘?‘-‘?‘*‘?‘/‘?‘(‘?‘)‘?‘#‘?};
?#define?OK?1
?#define?ERROR?0
?#define?OVERFLOW?-2
?typedef?char?SElemType;
?typedef?int?Status;
?typedef?struct?SNode?{
?int?data;
?struct?SNode?*next;
?}?SNode?*linkStack;
?Status?InitStack(linkStack?&S)?{
?S?=?NULL;
?return?OK;
?}
?bool?StackEmpty(linkStack?S)?{
?if?(!S)
?return?true;
?return?false;
?}
?Status?Push(linkStack?&S?SElemType?e)?{
?SNode?*p?=?new?SNode;
?if?(!p)?{
?return?OVERFLOW;
?}
?p->data?=?e;
?p->next?=?S;
?S?=?p;
?return?OK;
?}
?Status?Pushint(linkStack?&Sint?e)?{
?SNode?*p?=?new?SNode;
?if?(!p)?{
?return?OVERFLOW;
?}
?p->data?=?e;
?p->next?=?S;
?S?=?p;
?return?OK;
?}
?S
評論
共有 條評論