代码
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
while(1)
{
char ch;
double a[200]={0},sum=0,n;
int i=0;
cin>>a[0];
if(a[0]==0&&(getchar()=='
'))break;
while(1)
{
cin>>ch;
if(ch=='+'){cin>>a[++i];}
else if(ch=='-'){cin>>n;a[++i]=-n;}
else if(ch=='*'){cin>>n;a[i]*=n;}
else if(ch=='/'){cin>>n;a[i]/=n;}
if(getchar()=='
')break;
}
for(int j=0;j<=i;j++)
sum+=a[j];
printf("%.2f
",sum);
}
return 0;
}
心得:
看懂题目很重要