关于表达式求值的一组代码,有没有大神帮我改下??急!!

#include
#include
#include
#include
#define MAXSIZE 100
typedef int Bool;
#define true 1
#define false 0
typedef int elemtype;
char ch[7]={'+','-','*','/','(',')','#'};
int f1[7]={3,3,5,5,1,6,0};
int f2[7]={2,2,4,4,6,1,0};
int n=0;
typedef struct sqstack
{
elemtype stack[MAXSIZE];
int top;
}sqstack;
elemtype cton(char c)
{
switch(c)
{
case'+':return 0;
case'-':return 1;
case'*':return 2;
case'/':return 3;
case'(':return 4;
case')':return 5;
default:return 6;
}
}
char Compare(char c1,char c2)
{
int i1=cton(c1);
int i2=cton(c2);
if(f1[i1]>f2[i2]) return '>';
else if (f1[i1] else return'=';
}
int Operate(elemtype a,elemtype t,elemtype b)
{
int sum;
switch(t)
{
case 0: sum=a+b;break;
case 1: sum=a-b;break;
case 2: sum=a*b;break;
default:sum=a/b;
}
return sum;
}
int EvaluateExpression()
{
char c;
int i=0,sum=0;
int k=1,j=1;
elemtype x,t,a,b;
sqstack OPTR,OPND;
Initstack(&OPTR);
Push(&OPTR,cton('#'));
Initstack(&OPND);
c=getchar();
while(c!='#'||ch[Gettop(OPTR)]!='#')
{
if(isdigit(c))
{
sum=0;
while(isdigit(c))
{
if(!j)
{
sum=sum*10-(c-'0');
}
else sum=sum*10+(c-'0');
c=getchar();
}
Push(&OPND,sum);
j=1;
}
else if(k)
{
switch(Compare(ch[Gettop(OPTR)],c))
{
case' c=getchar();
break;
case'=': Pop(&OPTR,&x);
c=getchar();
case'>': Pop(&OPTR,&t);
Pop(&OPND,&b);
Pop(&OPND,&a);
Push(&OPND,Operate(a,t,b));
break;
}
}
}
return (Gettop(OPND));
}
elemtype Gettop(sqstack s)
{
if(s.top==0)
{
printf("ERROR,underflow\n");return 0;
}
else
return s.stack[s.top];
}
void Initstack(sqstack s)
{
s->top=0;
}
void Pop(sqstack *s,elemtype *x)
{
if(s->top=0) printf("ERROR,underflow!\n");
else
{
*x=s->stack[s->top];
s->top--;
}
}
void Push(sqstack *s,elemtype x)
{
if(s->top==MAXSIZE-1) printf("ERROR,Overflow!\n");
else
{
s->top++;
s->stack[s->top]=x;
}
}
bool StackEmpty(sqstack S)
{
if(S.top==0) return true;
else return false;
}
void main()
{
int result;
system("color 1f");
system("mode con:cols=80 lines=35");
printf("
*********欢迎使用表达式求值小程序**********\n\n");
printf("请输入您的算数表达(以#号键结束):");
result=EvaluateExpression();
printf("表达式的计算结果是:%d",result);
printf("**********感谢使用表达式求值小程序**********\n\n");
return 0;
}

http://blog.csdn.net/flyfy1/article/details/5309551