标签:hdu
one + two = three four + five six = zero seven + eight nine = zero + zero =
3 90 96
水题。
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; typedef __int64 ll; char str[11][10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; char s[20]; int main() { int res,i,j,n,sum,fact1,fact2,ans; while(scanf("%s",s)!=EOF){ fact1=fact2=0; for(i=0;i<10;i++) if(strcmp(s,str[i])==0) break; fact1=i; while(scanf("%s",s)){ if(s[0]==' ') continue; if(s[0]=='+') break; for(i=0;i<10;i++) if(strcmp(s,str[i])==0) break; fact1=fact1*10+i; } while(scanf("%s",s)){ if(s[0]==' ') continue; if(s[0]=='=') break; for(i=0;i<10;i++) if(strcmp(s,str[i])==0) break; fact2=fact2*10+i; } if(fact1==0 && fact2==0) break; printf("%d\n",fact1+fact2); } return 0; }
标签:hdu
原文地址:http://blog.csdn.net/u013068502/article/details/44983993