暴力破解a+b
A + B
http://www.nowcoder.com/questionTerminal/5fb3548802bb4a13a10c2e53a6fbfdd9
#include <stdio.h> #include <string.h> char num[10][6]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int main() { int a,b,i; char s[6]; while(scanf("%s",&s)!=EOF) { for(i=0;i<10;i++) { if(!strcmp(num[i], s)) { a=i; break; } } scanf("%s",&s); if(strcmp(s,"+")!=0) { a*=10; for(i=0;i<10;i++) { if(!strcmp(num[i], s)) { a+=i; break; } } scanf("%s",&s); scanf("%s",&s); for(i=0;i<10;i++) { if(!strcmp(num[i], s)) { b=i; break; } } scanf("%s",&s); if(!strcmp(s,"=")) { printf("%d\n",a+b); } else{ b*=10; for(i=0;i<10;i++) { if(!strcmp(num[i], s)) { b+=i; break; } } scanf("%s",&s); printf("%d\n",a+b); } } else{ scanf("%s",&s); for(i=0;i<10;i++) { if(!strcmp(num[i], s)) { b=i; break; } } scanf("%s",&s); if(a==0&b==0) break; else printf("%d\n",a+b); } } return 0; }
多次输入,然后条件判断(•̀ᴗ•́)و