简易四则运算计算器可运行代码.docVIP

  • 38
  • 0
  • 约8.58千字
  • 约 17页
  • 2018-01-03 发布于河南
  • 举报
简易四则运算计算器可运行代码

简易四则运算计算器可运行代码 #includestdio.h #includestring.h #includestdlib.h #includegraphics.h #includemath.h #includeconio.h #define Stack_Size 50 typedef struct { char elem[Stack_Size]; int top; }SepStack; typedef struct { int elem[Stack_Size]; int top; }SepStackOperand; typedef struct //运算符栈的定义 { char elem[Stack_Size]; int top; }SeqStack; typedef struct //运算数栈的定义 { int elem[Stack_Size]; int top; }SeqStackOperand; void CalFace(); //鼠标按键响应 void MainFace(); //界面 char ops[7]={+, -, *, /, (, ), #}; int cmp[7][7]= { {2,2,1,1,1,2,2}, {2,2,1,1,1,2,2}, {2,2,2,2,1,2,2}, {2,2,2,2,1,2,2}, {1,1,1,1,1,3,0}, {2,2,2,2,0,2,2}, {1,1,1,1,1,0,3} }; void InitStack(SeqStack*S) //初始化运算符栈 { S-top=-1; } void InitStacknOperand(SeqStackOperand*S) //初始化运算数栈 { S-top=-1; } int IsEmpty(SeqStack*S) //判断栈S为空栈时返回值为真,反之为假 { return (S-top==-1?TRUE:FALSE); } int IsEmptynOperand(SeqStackOperand*S) //判断栈S为空栈时返回值为真,反之为假 { return (S-top==-1?TRUE:FALSE); } int IsFull(SeqStack*S) //判断栈S为满栈时返回值为真,反之为假 { return (S-top==Stack_Size-1?TRUE:FALSE); } int IsFullOperand(SeqStackOperand*S) //判断栈S为满栈时返回值为真,反之为假 { return (S-top==Stack_Size-1?TRUE:FALSE); } int Push(SeqStack*S, char x) //运算符栈入栈函数 { if(S-top==Stack_Size-1) { printf(Stack is full!\n); return FALSE; } else { S-top++; S-elem[S-top]=x; return TRUE; } } int PushOperand(SeqStackOperand*S, int x) //运算数栈入栈函数 { if(S-top==Stack_Size-1) { printf(Stack is full!\n); return FALSE; } else { S-top++; S-elem[S-top]=x; return TRUE; } } int Pop(SeqStack*S, char *x) //运算符栈出栈函数 { if(S-top==-1) { printf(运算符栈空!\n); return FALSE; } else { *x=S-elem[S-top]; S-top--; return TRUE; } } int PopOperand(SeqStackOperand*S, int *x) //运算数栈出栈函数 { if(S-top==-1) { printf(运算数栈空!\n); return FALSE; } else { *x=S-elem[S-top]; S-top--; return TRUE; } } char GetTop(SeqStack*S) //运算符栈取栈顶元素函数 { if(S-top==-1) { printf(运算符栈空!\n); return FALSE; } el

文档评论(0)

1亿VIP精品文档

相关文档