one + two = three four + five six = zero seven + eight nine = zero + zero =樣例輸出:
3 90 96來源:
#include#include using namespace std; int main() { string a,b; int s1=0,s2=0,s; loop:while(cin>>a) { if(a=="zero") s1=s1*10+0; else if(a=="one") s1=s1*10+1; else if(a=="two") s1=s1*10+2; else if(a=="three") s1=s1*10+3; else if(a=="four") s1=s1*10+4; else if(a=="five") s1=s1*10+5; else if(a=="six") s1=s1*10+6; else if(a=="seven") s1=s1*10+7; else if(a=="eight") s1=s1*10+8; else if(a=="nine") s1=s1*10+9; else if(a=="+") break; } while(cin>>b) { if(b=="zero" && s2 ==0 && s1==0) return 0; else if(b=="zero") s2=s2*10+0; else if(b=="one") s2=s2*10+1; else if(b=="two") s2=s2*10+2; else if(b=="three") s2=s2*10+3; else if(b=="four") s2=s2*10+4; else if(b=="five") s2=s2*10+5; else if(b=="six") s2=s2*10+6; else if(b=="seven") s2=s2*10+7; else if(b=="eight") s2=s2*10+8; else if(b=="nine") s2=s2*10+9; else if(b=="=") break; } s=s1+s2; if(s!=0) { cout<