ZOJ-2971
来源:互联网 发布:淘宝开店怎么做代理商 编辑:程序博客网 时间:2024/06/11 22:56
比较简单的模拟题,英文数字转整数输出
#include<iostream>#include<sstream>#include<string>#include<map>using namespace std;int main(){map<string, int> mp;mp["zero"] = 0;mp["one"] = 1;mp["two"] = 2;mp["three"] = 3;mp["four"] = 4;mp["five"] = 5;mp["six"] = 6;mp["seven"] = 7;mp["eight"] = 8;mp["nine"] = 9;mp["ten"] = 10;mp["eleven"] = 11;mp["twelve"] = 12;mp["thirteen"] = 13;mp["fourteen"] = 14;mp["fifteen"] = 15;mp["sixteen"] = 16;mp["seventeen"] = 17;mp["eighteen"] = 18;mp["nineteen"] = 19;mp["twenty"] = 20;mp["thirty"] = 30;mp["forty"] = 40;mp["fifty"] = 50;mp["sixty"] = 60;mp["seventy"] = 70;mp["eighty"] = 80;mp["ninety"] = 90;int n;string line, word;cin >> n >> ws;while (n--){getline(cin, line);istringstream is(line);int thousand = 0, hundred = 0, million = 0, other = 0;while (is >> word){if (word == "and")continue;if (word == "hundred"){hundred = other * 100;other = 0;}else if (word == "thousand"){thousand = (hundred + other) * 1000;hundred = 0;other = 0;}else if (word == "million"){million = (hundred + other) * 1000000;hundred = 0;other = 0;}else{other += mp[word];}}cout << (million + thousand + hundred + other) << endl;}return 0;}
0 0
- ZOJ-2971
- zoj 2971 答案
- zoj 2971 解题思路
- ZOJ 2971 模拟 (G)
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- Oracle数据库的创建与删除(DROP DATABASE语句)
- Spring事务处理时自我调用的解决方案及一些实现方式的风险
- poj 2151 (DP)
- Android中TabHost中实现标签的滚动以及一些TabHost开发的奇怪问题
- test
- ZOJ-2971
- POJ 2184 Cow Exhibition(01背包变形)
- Notification的功能与用法
- Get nth element of an array in Ruby?
- 小练习 ---- 简单的多线程模拟
- 找出字符串中第一个出现次数最多的字符
- BZOJ2134
- ExpandableListView(一)替换系统默认的箭头
- 只输出匹配的模式--正则表达式的一个应用