#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <math.h>
#include<iostream>
#include <map>
using namespace std;
#define INF 0xfffff;//0x代表十六进制
#define M 10050
string s, s1, s2[11] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
int sum1, sum2;
void cacu(int f, string s1)
{
for (int i = 0; i < 11; i++)
{
if (s1.compare(s2[i]) == 0)
{
if (f) sum1=sum1 * 10 + i;
else sum2=sum2 * 10 + i;
break;
}
}
}
int main()
{
while (getline(cin, s))
{
s1 = "";
sum1 = sum2 = 0;
int l = s.length();
int f = 1, f1;// 加号左右标记
for (int i = 0; i < l-1; i++) // 最后一个是等号
{
if (s[i] == '+') f = 0;
else if (s[i] >= 'a' &&s[i]<= 'z')
{
s1+= s[i]; //连接
f1 = 1;
}
else if(f1)
{
cacu(f,s1);
s1 = "";
f1 = 0;
}
}
if (sum1 == 0 && sum2 == 0) break;
else cout << sum1 + sum2 << endl;
}
}
HDOJ1228(字符串A+B)
最新推荐文章于 2020-05-26 09:07:09 发布