1810: water problem II
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 90 Solved: 53
Submit Status Web Board
Description
相信大家对A+B问题最熟悉了。
实验室有个女人(传说中的潘同学)经常卡在这种题目上。。。
有一次,他边敷着面膜边做题,遇见了这样一个题目:
输入两个表示数的英文单词,输出他们的和。(当然输入的是英文,输出的是10进制数)
他头脑太ben了,想了半天没想出来怎么做?你能帮助他么?
Input
多组输入数据。每组数据输入两个表示数的英文单词(输入的数据是0-9)
Output
对于每组数据输出一个和。
Sample Input
one two
Sample Output
3
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[10];
char b[10];
int zz(char *s)
{
if(strcmp(s,"zero")==0)
return 0;
else if(strcmp(s,"one")==0)
return 1;
else if(strcmp(s,"two")==0)
return 2;
else if(strcmp(s,"three")==0)
return 3;
else if(strcmp(s,"four")==0)
return 4;
else if(strcmp(s,"five")==0)
return 5;
else if(strcmp(s,"six")==0)
return 6;
else if(strcmp(s,"seven")==0)
return 7;
else if(strcmp(s,"eight")==0)
return 8;
else if(strcmp(s,"nine")==0)
return 9;
}
int main()
{
while(scanf("%s%s",a,b)!=EOF)
{
int x=zz(a);
int y=zz(b);
printf("%d\n",x+y);
}
return 0;
}