Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9374 Accepted Submission(s): 5364
one + two = three four + five six = zero seven + eight nine = zero + zero =
3 90 96
#include <cstdio> #include <string.h> int f(char str[]){ if(!strcmp(str,"zero"))return 0; if(!strcmp(str,"one"))return 1; if(!strcmp(str,"two"))return 2; if(!strcmp(str,"three"))return 3; if(!strcmp(str,"four"))return 4; if(!strcmp(str,"five"))return 5; if(!strcmp(str,"six"))return 6; if(!strcmp(str,"seven"))return 7; if(!strcmp(str,"eight"))return 8; if(!strcmp(str,"nine"))return 9; } int main(){ char str[30]; int a,b; while(1){ a=b=0; while(1){ scanf("%s",str); if(!strcmp(str,"+"))break; else a=a*10+f(str); } while(1){ scanf("%s",str); if(!strcmp(str,"="))break; else b=b*10+f(str); } if(a==0&&b==0)break; printf("%d\n",a+b); } }