眼瞎了A和B都在区间[1,1000]
C++ 代码
#include<iostream>
using namespace std;
int n1,n2;
bool f1,f2,f3,f4;
string a,b;
int main()
{
f1=f2=f3=f4=true;
cin>>a;
getchar();
getline(cin,b);
for(int i=0;i<a.size();i++)
{
if(a[i]>='0'&&a[i]<='9')
{
n1=n1*10+(a[i]-'0');
}
else{
f1=false;
break;
}
}
for(int i=0;i<b.size();i++)
{
if(b[i]>='0'&&b[i]<='9')
{
n2=n2*10+(b[i]-'0');
}
else{
f2=false;
break;
}
}
if(n1>1000||n1<1)f3=false;
if(n2>1000||n2<1)f4=false;
if(f1&&f3)cout<<n1;
else cout<<"?";
cout<<" + ";
if(f2&&f4)cout<<n2;
else cout<<"?";
cout<<" = ";
if(f1&&f2&&f3&&f4)
cout<<n1+n2;
else cout<<"?";
return 0;
}