HDU 1228 简单题

#include  <iostream>
using namespace std;
char num[10][10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int lookup(char *t)
{
	for(int i = 0;  i < 10; i++)
		if(strcmp(t, num[i]) == 0)
			return i;
}
int main()
{
	int a, b;
	char temp[10]; 
	while(scanf("%s", temp) != EOF)
	{
		a = lookup(temp);
		while(scanf("%s", temp), strcmp(temp, "+") != 0)
		{
			a = a * 10 + lookup(temp);
		}
		b = 0;
		while(scanf("%s", temp), strcmp(temp, "=") != 0)
		{
			b = b* 10 + lookup(temp);
		}
		if(a == 0 && b==0)
			break;
		cout << a + b << endl;
	}
	return 0;
}

你可能感兴趣的:(include)