#include<stdio.h> #include<string.h> #include<iostream> using namespace std; #define MAXSIZE 100 typedef struct{ char *base; char *top; }Sqstack; //手动构造预测分析表 42个字符串 char* str[6][7]={" " , "i" , "+" , "*" , "(" , ")" , "#" , "E" , "TH" , " " , " " , "TH" , " " , " ", "H" , " " , "+TH" , " " ," " , "e" ,"e", "T" , "FY" , " " , " " , "FY" , " " , " ", "Y" , " " , "e" , "*FY" , " " , "e" , "e", "F" , "i" , " " , " " , "(E)" , " " , " " }; /*初始化顺序栈*/ void Creatstack(Sqstack &S) { S.base = new char[MAXSIZE];/*base指向第0个元素*/ S.top = S.base; } /*判断栈是否为空*/ int stackempty(Sqstack &S) { if(S.base == S.top) return 1; else return 0; } /*入栈*/ void push(Sqstack &S,char e) { *S.top++ = e; } /*出栈*/ void pop(Sqstack &S) { --S.top; } /*获取栈顶元素*/ char gettop(Sqstack &S) { --S.top; return *S.top; } /*把栈里的内容输出*/ void showstack(Sqstack &S) { int i = 0;//记步 while(S.top != S.base) { printf("%c",*S.base); S.base++; i++; } //把栈还原成原来的样子 while(i != 0) { S.base--; i--; } } void showinput(char *p) { int i = 0; while(*p != '