Wrong Answer.wrong answer On line 1 column 1, read (ASCII 0), expected x.
错误答案。错误答案在第1行第1列,读取(ASCII 0),应为x。
#include<bits/stdc++.h>
using namespace std;
int x,pl,uk,f = 1;
char s,v;
int main()
{
freopen("t.txt","r",stdin);
while(cin >> s)
{
if(s == '=') break;
if(s == '-' || s == '+')
{
pl += x * f;
x = 0,f = 1;
if(s == '-') f = -1;
continue;
}
if(s < '0' || s > '9')
{
v = s;
uk += x * f;
x = 0;
continue;
}
x = x * 10 + s - 48;
}
pl += x * f;
x = 0;
f = 1;
while(cin >> s)
{
if(s == '-' || s == '+')
{
pl -= x * f;
x = 0,f = 1;
if(s == '-') f = -1;
continue;
}
if(s < '0' || s > '9')
{
uk -= x * f;
x = 0;
continue;
}
x = x * 10 + s - 48;
}
pl -= x * f;
double ans = -1.0 * pl / uk;
if(ans == 0) printf("0.000\n");
else printf("%c=%.3lf\n",v,ans);
return 0;
}