电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

数据结构表达式求值

数据结构表达式求值_第1页
1/12
数据结构表达式求值_第2页
2/12
数据结构表达式求值_第3页
3/12
下载后可任意编辑数据结构表达式求值 #includeusing namespace std;#define TRUE 1#define FALSE 0#define Stack_Size 20#define Stack_Float 30/*建立字符栈*/ typedef struct{ char elem[Stack_Size];//存储定义 int top;}Stack_char; void InitStack(Stack_char*S)//初始化顺序栈 { S->top=-1; }int Push(Stack_char *S,char x)//进栈 { if(S->top==Stack_Size-1) return (FALSE); S->top++; S->elem[S->top]=x; return (TRUE);}int Pop(Stack_char*S,char*x)//出栈 { if(S->top==-1) return(FALSE); else { *x=S->elem[S->top]; S->top--; return(TRUE); }}int GetTop(Stack_char*S,char*x)// 取栈顶{ if(S->top==-1) return(FALSE); else {下载后可任意编辑 *x=S->elem[S->top]; return(TRUE); }}char GetTop(Stack_char S){ char x; GetTop(&S,&x); return x;}//建立数字栈 typedef struct//建立 { float elem[Stack_Float]; int top;}Stack_float;void InitStack(Stack_float*S)//初始化 { S->top=-1;}int Push(Stack_float*S,float e) //进栈 { if(S->top==Stack_Float-1) return(FALSE); else { S->top++; S->elem[S->top]=e; return(TRUE); }}int Pop(Stack_float*S,float*x)//出栈 { if(S->top==-1) return(FALSE); else { *x=S->elem[S->top]; S->top--; return(TRUE); }}int GetTop(Stack_float*S,float*x)// 取栈顶{下载后可任意编辑 if(S->top==-1) return(FALSE); else { *x=S->elem[S->top]; return(TRUE); }}float GetTop(Stack_float S){ float x; GetTop(&S,&x); return x;} bool In(char ch)//推断字符 { if(ch=='+'||ch=='-'||ch=='*'||ch=='/'||ch=='('||ch==')'||ch=='#') return (TRUE); else return(FALSE); } float GetNumber(char*ch)//转化数码 { return (*ch-48);}float Execute(float a,char op,float b){ switch(op) { case'+':return(a+b);break; case'-':return(a-b);break; case'*':return(a*b);break; case'/':return(a/b);break; default:cout<<"不能运算";break; }} char Compare(char x,char ch){ if(x=='+'||x=='-') if(ch=='+'||ch=='-'||ch==')'||ch=='#') return ('>'); else return ('<'); if(x=='*'||x=='/') if(ch=='(') return(...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

数据结构表达式求值

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部