int main(){int i,l,key;char tmp;char exp[MaxSize];char postexp[MaxSize];char prefexp[MaxSize];Menu();scanf("%d",&key);switch(key){case 1:printf("\n***********后缀表达式求值***********\n");printf("\n请输入一个合法数学表达式:"); scanf("%s",exp);printf("\n中辍表达式:%s\n",exp);trans1(exp,postexp);printf("\n表达式的值:%g\n",compvalue1(postexp));system("pause");main();break;case 2:printf("\n***********前缀表达式求值***********\n");printf("\n请输入一个合法数学表达式:"); scanf("%s",exp);printf("\n中辍表达式:%s\n",exp);l=strlen(exp);for(i=0;i<(l-1)/2;i ){tmp=exp[i];exp[i]=exp[l-i-1];exp[l-i-1]=tmp;}trans2(exp,prefexp);printf("\n表达式的值:%g\n",compvalue2(prefexp));system("pause");main();break;case 0:Exit();break;default :Error();main();}return 0;}
下载算法表达式求值.cpp用户还喜欢
- 18477 文章数
- 500万+ 热度


评论