我在编译器上是可以通过样例的,但是在这里全部报的错误是RE,这是咋回事,哪里出了问题,大佬指点一下
#include <bits/stdc++.h>
using namespace std;
//unordered_map<char,char> mp;
int main()
{
int n;
scanf("%d",&n);
getchar();
vector<string> opnd;
for(int i = 0;i < n;i++)
{
string s;
getline(cin,s);
opnd.push_back(s);
}
char ch;
for(int i = 0;i < n;i++)
{
if(opnd[i][0] == 'a' || opnd[i][0] == 'b' || opnd[i][0] == 'c')
{
ch = opnd[i][0];
int x,y;
string str;
for(int j = 2;j < opnd[i].size();j++)
{
if(opnd[i][j] == ' ')
{
x = stoi(str);
str = "";
continue;
}
str += opnd[i][j];
}
y = stoi(str);
if(ch == 'a')
{
cout << x << "+" << y << "=" << x+y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(x+y)+5 << endl;
}
else if(ch == 'b'&&x>y)
{
cout << x << "-" << y << "=" << x-y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(x-y)+5 << endl;
}
else if(ch == 'b'&&x<y)
{
cout << x << "-" << y << "=" << x-y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(abs(x-y))+5+1 << endl;
}
else if(ch == 'c')
{
cout << x << "*" << y << "=" << x*y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(x*y)+5 << endl;
}
}
else
{
int x,y;
string str;
for(int j = 0;j < opnd[i].size();j++)
{
if(opnd[i][j] == ' ')
{
x = stoi(str);
str = "";
continue;
}
str += opnd[i][j];
}
y = stoi(str);
if(ch == 'a')
{
cout << x << "+" << y << "=" << x+y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(x+y)+5 << endl;
}
else if(ch == 'b'&&x>y)
{
cout << x << "-" << y << "=" << x-y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(x-y)+5 << endl;
}
else if(ch == 'b'&&x<y)
{
cout << x << "-" << y << "=" << x-y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(abs(x-y))+5+1 << endl;
}
else if(ch == 'c')
{
cout << x << "*" << y << "=" << x*y << endl;
cout << (int)log10(x)+(int)log10(y)+(int)log10(x*y)+5 << endl;
}
}
}
//system("pause");
return 0;
}