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; }
相关文章推荐
- POJ 2572(Seek the Name, Seek the Fame) KMP中next数组的应用
- POJ---3337 Expression Evaluator[模拟运算符]
- POJ 2014:Flow Layout 模拟水题
- poj 3087 直接模拟
- POJ 1573 Robot Motion(小模拟)
- poj1027--The Same Game(模拟)
- POJ(1068)(模拟)(栈)思想
- POJ 2632-Crashing Robots(模拟-robot移动)
- poj-3087-Shuffle'm Up-模拟
- An Old Stone Game(poj1694模拟与排序)
- POJ 3414 BFS 模拟求最快方式
- POJ-1009(模拟) #by nobody
- poj 2106 Boolean Expressions(模拟)
- POJ训练计划3993_Emag eht htiw Em Pleh(模拟)
- 【贪心】【模拟】[POJ1877]Flooded!
- POJ 1008 Maya Calendar 水模拟
- poj 2993 Emag eht htiw Em Pleh 模拟
- POJ-1835 宇航员 模拟
- UVa 712/POJ 1105/ZOJ 1150 S-Trees(用数组模拟二叉树)
- poj 1068 Parencodings 大模拟 水题 暑假第7题