我下载了一组RE的样例跑本地结果还是对的???
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<cstring>
using namespace std;
void splite(string str,vector<string>&res, char pattern){
istringstream is(str);
string temp;
while(getline(is,temp,pattern)){
res.push_back(temp);
}
return ;
}
string get_ans(string op,int a,int b){
string res="";
if(op=="a")
return res+to_string(a)+"+"+to_string(b) + "=" + to_string(a+b);
if(op=="b")
return res+to_string(a)+"-"+to_string(b) +"="+ to_string(a-b);
if(op=="c")
return res+to_string(a)+"*"+to_string(b) +"="+ to_string(a*b);
}
int getint(string s){
int ans=0;
for(int i=0;i<s.size();i++){
int t=s[i]-'0';
ans=ans*10+t;
}
return ans;
}
int main(){
int n;
cin>>n;
string op;
string ss;getchar();
for(int i=0;i<n;i++){
getline(cin,ss);
vector<string>res;
splite(ss,res,' ');
if(res.size()==3){
op = res[0];
int x =getint(res[1]);
int y= getint(res[2]);
string ans=get_ans(op,x,y);
cout<<ans<<'\n'<<ans.size()<<endl;
}else{
int x =getint(res[0]);
int y= getint(res[1]);
string ans=get_ans(op,x,y);
cout<<ans<<'\n'<<ans.size()<<endl;
}
}
return 0;
}
求大佬能解答解答\t\t\t\t\t\t