题解 | #A + B#
A + B
https://www.nowcoder.com/practice/5fb3548802bb4a13a10c2e53a6fbfdd9
#include <iostream> using namespace std; int main() { string engNum[10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; string s; int temp=0; int res=0; while(cin>>s){ if(s == "+"){ res+=temp; temp=0; } if(s == "="){ cout<<(res+temp==0?"":to_string(res+temp))<<endl; res=0;temp=0; } for(int i =0;i<10;i++) if(s == engNum[i]){ temp*=10; temp+=i; } } } // 64 位输出请用 printf("%lld")
不要用split的思想