好久没做题,要做就做水题。。。。
用C++中的map映射下数字和字符串 其他就没什么了
[cpp] #include #include #include using namespace std; mapm; int main() { m["one"]=1; m["two"]=2; m["three"]=3; m["four"]=4; m["five"]=5; m["six"]=6; m["seven"]=7; m["eight"]=8; m["nine"]=9; m["zero"]=0; char s[15]; int a,b; while(cin>>s) { a=b=0; while(strcmp(s,"+")) { a=a*10+m[s]; cin>>s; } cin>>s; while(strcmp(s,"=")) { b=b*10+m[s]; cin>>s; } if(a==0&&b==0)break; cout< } return 0; }
#include #include #include using namespace std; mapm; int main() { m["one"]=1; m["two"]=2; m["three"]=3; m["four"]=4; m["five"]=5; m["six"]=6; m["seven"]=7; m["eight"]=8; m["nine"]=9; m["zero"]=0; char s[15]; int a,b; while(cin>>s) { a=b=0; while(strcmp(s,"+")) { a=a*10+m[s]; cin>>s; } cin>>s; while(strcmp(s,"=")) { b=b*10+m[s]; cin>>s; } if(a==0&&b==0)break; cout< } return 0; }
} return 0; }