#include<stdio.h>
#include<string.h>
int fun(char a[])
{
if(strcmp(a,"zero")==0) return 0;
if(strcmp(a,"one")==0) return 1;
if(strcmp(a,"two")==0) return 2;
if(strcmp(a,"three")==0) return 3;
if(strcmp(a,"four")==0) return 4;
if(strcmp(a,"five")==0) return 5;
if(strcmp(a,"six")==0) return 6;
if(strcmp(a,"seven")==0) return 7;
if(strcmp(a,"eight")==0) return 8;
if(strcmp(a,"nine")==0) return 9;
}
int main()
{
char a[6][6];
while(scanf("%s %s",a[0],a[1])!=EOF)
{
int left=0,right=0;
if(a[1][0]!='+')
{
scanf("%s",&a[2]);
left=fun(a[0])*10+fun(a[1]);
}
else left=fun(a[0]);
scanf("%s %s",a[3],a[4]);
if(a[4][0]!='=')
{
scanf("%s",&a[5]);
right=fun(a[3])*10+fun(a[4]);
}
else right=fun(a[3]);
printf("%d\n",left+right);
}
return 0;
}
还是A+B
时间限制:
1000 ms | 内存限制:
65535 KB
难度:
1
-
描述
-
输入两个小于100的正整数A和B,输出A+B;A,B均为每位数字对应的英文字母,结果为十进制数。
-
输入
- A,B。 输出
- A+B; 样例输入
-
one + two = one + two zero =
样例输出
-
3 21