1、#include#include#includedouble jisuan(char a)int i=1,j,k,m,cnt=0,t1=0,t2=0,t3=0;char nibo50,zhan250;double x,n,l,z=0,zhan350;typedef structdouble d1;int d2;dd;typedef structdd data50;int top;zhan1;zhan1 *shu;shu=(zhan1 *)malloc(sizeof(zhan1);shu-top=0;while(ai!=0)if(ai=0shu-datashu-top.d2=+cnt;nibo+
2、t1=0+shu-datashu-top.d2;nibot1+1=0;else if(ai=()zhan2+t2=ai;i+;else if(ai=)j=t2;while(zhan2j!=()nibo+t1=zhan2j;nibot1+1=0;j-;t2=j-1;i+;else if(ai=+)while(t20nibot1+1=0;t2-;zhan2+t2=ai;i+;else if(ai=-)if(ai-1=$)a0=0;i=0;else if(ai-1=()ai-1=0;ai-2=(;i=i-2;t2-;elsewhile(t20nibot1+1=0;t2-;zhan2+t2=ai;i+
3、;else if(ai=*|ai=/)while(zhan2t2=*|zhan2t2=/|zhan2t2=|zhan2t2=#)nibo+t1=zhan2t2;nibot1+1=0;t2-;zhan2+t2=ai;i+;else if(ai=|ai=#)while(zhan2t2=|zhan2t2=#)nibo+t1=zhan2t2;nibot1+1=0;t2-;zhan2+t2=ai;i+;while(t20)nibo+t1=zhan2t2;nibot1+1=0;t2-;j=1;t3=0;while(j=0itop;i+)if(int)(niboj-0)=shu-datai.d2)m=i;b
4、reak;zhan3+t3=shu-datam.d1;else if(niboj=+)zhan3t3-1=zhan3t3-1+zhan3t3;t3-;else if(niboj=-)zhan3t3-1=zhan3t3-1-zhan3t3;t3-;else if(niboj=*)zhan3t3-1=zhan3t3-1*zhan3t3;t3-;else if(niboj=/)zhan3t3-1=zhan3t3-1/zhan3t3;t3-;else if(niboj=)zhan3t3-1=pow(zhan3t3-1,zhan3t3);t3-;else if(niboj=#)zhan3t3=sqrt(zhan3t3);j+;return zhan3t3;void main()for(;)char x,a50;double jieguo;int i=0;a0=$;printf(“#表示开方,表示乘方(支持负数)n“);printf(“请输入表达式,退出请输入 q:nn“);scanf(“%c“,if(x=q) break;while(x!=n)a+i=x;scanf(“%c“,ai+1=0;jieguo=jisuan(a);printf(“n“);printf(“结果为:%lf“,jieguo);printf(“nnnnn“);