显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cstring>
#define syy myson
using namespace std;
string a;
char x;
int len,num=0,numx=0,sum=0,lnumx=0,lsum=0,rnumx=0,rsum=0,flag=1,i;
double ans;
int Main()
{
freopen("computer.in","r",stdin);freopen("computer.out","w",stdout);
cin>>a;
len=a.size();
for(i=0;i<len;i++)
{
if(a[i]>='a'&&a[i]<='z')
{
x=a[i];
if(i==0)numx++;
else
{
numx+=num*flag;
num=0;
}
}
else if(a[i]>='0'&&a[i]<='9')
{
num=(num*10+int(a[i])-48);
}
else if(a[i]=='+')
{
sum+=num*flag;
num=0;
flag=1;
}
else if(a[i]=='-')
{
sum+=num*flag;
num=0;
flag=-1;
}
else if(a[i]=='=')
{
lnumx=numx;
lsum=sum+num*flag;
num=0;
numx=0;
sum=0;
flag=1;
}
}
sum=lsum-sum-num*flag;
numx=numx-lnumx;
ans=double(sum)/double(numx);
if(ans==-0)ans=0;
printf("%c=%0.3lf",x,ans);
return 0;
}
int main(){;}
int syy=Main();