这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1228
水题~~~
// Accepted 1228 0MS 200K 641 B C++
#include
#include
using namespace std;
char map[][10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int search(char s[])
{
for(int i=0; i<10; i++)
if (strcmp(s,map[i])==0)
return i;
}
int main()
{
char s[10];
int a, b;
while (1)
{
a=0;
while (scanf("%s", s) && strcmp(s, "+") !=0 )
a= a*10 + search(s);
b=0;
while (scanf("%s", s) && strcmp(s, "=") !=0)
b= b*10 + search(s);
if( a==0 && b==0) break;
printf("%d\n", a+b);
}
return 0;
}