本人代码:
#include <iostream>
#include <iomanip>
using namespace std;
char ch,let;
long long l,r;
int line,f;
int gete()
{
int s=0;
while(true)
{
if('0'<=ch && ch<='9') s=s*10+ch-'0';
else if(ch=='+' || ch=='-' || ch=='=' || ch=='\n') return s;
else
{
let=ch;
ch=getchar();
if(!s) s=1;
return -s-1;
}
ch=getchar();
}
}
void readel()
{
while(true)
{
if(ch=='=') return;
if(ch=='+')
{
f=1;
ch=getchar();
}
else if(ch=='-')
{
f=-1;
ch=getchar();
}
line=gete();
if(line<0) l+=f*(-line-1);
else r-=f*line;
}
}
void reader()
{
while(true)
{
if(ch=='\n') return;
if(ch=='+')
{
f=1;
ch=getchar();
}
else if(ch=='-')
{
f=-1;
ch=getchar();
}
line=gete();
if(line>=0) r+=f*line;
else l-=f*(-line-1);
}
}
int main()
{
f=1;
ch=getchar();
readel();
f=1;
ch=getchar();
reader();
float ans=float(r)/float(l);
cout<<let<<'='<<setiosflags(ios::fixed)<<setprecision(3)<<ans;
return 0;
}