stacka[top]=item; }
string stack::pop(void) //出栈操作 {
if(empty()) {
cerr<<"stack empty, cannot pop."<<endl; exit(1) ; }
string item=stacka[top]; top--;
return item; }
string stack::gettop(void) const //取栈顶操作 {
if(empty()) {
cerr<<"stack empty, cannot gettop."<<endl; exit(1) ; }
return stacka[top]; }
static stack wordStack; //符号栈 static int noOfQuet=0; //静态四元式个数记录 static int noOfT = 1; //静态状态个数记录
void main(){ //主函数 char yesOrNo; //进行一个循环操作控制 do{ cout<<"请输入算术表达式:"<<endl; noOfT = 1; //每次结束询问 ZMachine(); cout<<endl<<"Continue?Yes or Not:"; cin>>yesOrNo; //输入“Y”则继续 }while(yesOrNo=='y'); //否则程序结束 }
bool ZMachine(){ //Z自动机 char w; cin>>w; w = EMachine(w); //调用E自动机