这个程序加了小数点后运行怎么不对?
#include
const int n0=60;
double mark1[n0+1];
char mark2[n0+1];
int a,b;
void Jisuan()
{
double x1,x2,x;
char operater;
operater=mark2[b--];
x2=mark1[a--];
x1=mark1[a--];
switch(operater){
case '+':x=x1+x2;break;
case '-':x=x1-x2;break;
case '*':x=x1*x2;break;
case '/':x=x1/x2;break;
}
mark1[++a]=x;
}
void main()
{
char c;
double v;
double m(0);
a=b=0;
cin>>c;
while(c!=';'){
switch(c)
{
case'+':
case'-':
while(b&&(mark2[b]!='('))
Jisuan();
mark2[++b]=c;
cin>>c;
break;
case'*':
case'/':
if(b&&((mark2[b]=='*')||(mark2[b]=='/')))
Jisuan();
mark2[++b]=c;
cin>>c;
break;
case'(':
mark2[++b]=c;
cin>>c;
break;
case')':
while(mark2[b]!='(')
Jisuan();
b--;
cin>>c;
break;
case'.':
cin>>c;
m=0.1*(c-'0');
cin>>c;
break;
default:
v=0;
do{
v=10*v+c-'0';
cin>>c;
}while((c>='0')&&(c<='9'));
v=m+v;
mark1[++a]=v;
}
}
while(b)
Jisuan();
cout<<"="<}
--------------------next---------------------
阅读(995) | 评论(0) | 转发(0) |