您的位置:首页 > 其它

poj2572 水模拟

2011-03-11 22:14 197 查看
#include <iostream>
#include <string>
using namespace std;
int trans(string s) {
int a=0;
for (int i=s.length()-1;i>=0;i--)
a=a*10+s[i]-'0';
return a;
}
int main() {
string s,s1,s2,s3;
while (cin >> s) {
if (s=="0+0=0") {
cout << "True" << endl;
break;
}
bool flag=true;
int p1=s.find("+");
int p2=s.find("=");
s1=s.substr(0,p1);
s2=s.substr(p1+1,p2-p1-1);
s3=s.substr(p2+1,s.length()-1-p2);
if (trans(s1)+trans(s2)!=trans(s3)) flag=false;
if (flag) cout << "True" << endl;
else cout << "False" << endl;
}
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: