标签:des style http color io os ar java for
//对字符串的处理很好
one + two = three four + five six = zero seven + eight nine = zero + zero =
3 90 96
#include<stdio.h> #include<string.h> char a[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int fun(char c[]) { //if(strcmp(a[0],c)==0) return 0; // if(strcmp(a[1],c)==0) return 1; // if(strcmp(a[2],c)==0) return 2; // if(strcmp(a[3],c)==0) return 3; // if(strcmp(a[4],c)==0) return 4; // if(strcmp(a[5],c)==0) return 5; // if(strcmp(a[6],c)==0) return 6; // if(strcmp(a[7],c)==0) return 7; // if(strcmp(a[8],c)==0) return 8; // if(strcmp(a[9],c)==0) return 9; int i; for(i=0;i<10;i++) if(strcmp(a[i],c)==0) return i; } int main() { char str1[10],str2[10]; int p,q; while(1) { p=q=0; while(scanf("%s",str1) && strcmp(str1,"+")!=0) p=p*10 + fun(str1); while(scanf("%s",str2) && strcmp(str2,"=")!=0) q=q*10 + fun(str2); if(p==0&&q==0) break; else printf("%d\n",p+q); } return 0; }
标签:des style http color io os ar java for
原文地址:http://blog.csdn.net/qq_16767427/article/details/40375601