标签:
one + two = three four + five six = zero seven + eight nine = zero + zero =
3 90 96
#include<stdio.h>
#include<string.h>
int f(char s[])
{
if(s[0] == ‘z‘) return 0;
else if(s[0] == ‘o‘) return 1;
else if(s[0] == ‘t‘ && s[1] == ‘w‘) return 2;
else if(s[0] == ‘t‘ && s[1] == ‘h‘) return 3;
else if(s[0] == ‘f‘ && s[1] == ‘o‘) return 4;
else if(s[0] == ‘f‘ && s[1] == ‘i‘) return 5;
else if(s[0] == ‘s‘ && s[1] == ‘i‘) return 6;
else if(s[0] == ‘s‘ && s[1] == ‘e‘) return 7;
else if(s[0] == ‘e‘) return 8;
else if(s[0] == ‘n‘) return 9;
else return -1;
}
int main(void)
{
char s[5];
while(scanf("%s",s) != EOF)
{
int a,b;
a = f(s);
while(scanf("%s",s) != EOF)
{
if(s[0] != ‘+‘ && s[0] != ‘=‘)
{
a *= 10;
a += f(s);
}
else if(s[0] == ‘+‘)
{
b = a;
a = 0;
}
else if(s[0] == ‘=‘)
break;
}
if(a || b)
printf("%d\n",a+b);
else
return 0;
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/wft1990/p/4297897.html