题目:http://acm.hdu.edu.cn/showproblem.php?pid=1228
ps:代码不为原创,不过自己觉得这种思路非常好,就转来(转自HDU id: 口翼)与大家分享。
#include <stdio.h>
#include <string.h>
char num[10][6]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int search(char ch[])
{
int i;
for(i=0;i<10;i++)
{
if(strcmp(ch,num[i])==0)
break;
}
return i;
}
int main()
{
char count[10];
int a,b;
while(1)
{
a=0;
while(scanf("%s",count)&&strcmp(count,"+")!=0)
a=a*10+search(count);
b=0;
while(scanf("%s",count)&&strcmp(count,"=")!=0)
b=b*10+search(count);
if(a==0&&b==0) return 0;
else
{
printf("%d\n",a+b);
}
}
return 0;
}
ps:代码不为原创,不过自己觉得这种思路非常好,就转来(转自HDU id: 口翼)与大家分享。
#include <stdio.h>
#include <string.h>
char num[10][6]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int search(char ch[])
{
}
int main()
{
}