hdu1228

/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <sstream>

typedef long long LL;
using namespace std;

string s;
string num[11];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	num[0] = "zero";
	num[1] = "one";
	num[2] = "two";
	num[3] = "three";
	num[4] = "four";
	num[5] = "five";
	num[6] = "six";
	num[7] = "seven";
	num[8] = "eight";
	num[9] = "nine";
	num[10] = "ten";
	while(getline(cin, s)){
		int a = 0, b = 0;
		int len = s.size();
		int l = 0, r = 0;
		int flag = 0;
		for (int i = 0; i < len; i++){
			if(s[i] == ' ' && !flag){
				r = i - 1;
				string str;
				int temp;
				str = s.substr(l, r - l + 1);
				for (int j = 0; j <= 10; j++){
					if(num[j] == str){
						temp = j;
						break;
					}
				}
				a = a * 10 + temp;
				l = i + 1;
			}
			if(s[i] == '+') {
				flag = 1;
				l = i + 2;
			}
			if(s[i] == ' ' && s[i - 1] != '+' && flag){
				r = i - 1;
				string str;
				int temp;
				str = s.substr(l, r - l + 1);
				for (int j = 0; j <= 10; j++){
					if(num[j] == str){
						temp = j;
						break;
					}
				}
				b = b * 10 + temp;
				l = i + 1;
			}
		}
		if(!a && !b) break;
		else{
			printf("%d\n", a + b);
		}
	}

	return 0;
}
/**/

 

全部评论

相关推荐

11-27 17:08
已编辑
牛客_产品运营部_私域运营
腾讯 普通offer 24k~26k * 15,年包在36w~39w左右。
点赞 评论 收藏
分享
10-27 17:26
东北大学 Java
点赞 评论 收藏
分享
尊嘟假嘟点击就送:加v细说,问题很大
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务