九度 题目1010:A + B
来源:互联网 发布:php架构师面试题 编辑:程序博客网 时间:2024/05/22 17:39
处理好字符串即可。代码:
#include <iostream>#include <string>#include <map>using namespace std;map<string, int> dict;string str;int a, b;void init(){dict["zero"] = 0;dict["one"] = 1;dict["two"] = 2;dict["three"] = 3;dict["four"] = 4;dict["five"] = 5;dict["six"] = 6;dict["seven"] = 7;dict["eight"] = 8;dict["nine"] = 9;}int string_to_int(const string& str){int ret = 0;for (size_t i=0, next=str.find(' '); next!=string::npos; i=next+1, next=str.find(' ',i)){ret = 10 * ret + dict[str.substr(i, next-i)];}return ret;}int main(){init();while (getline(cin, str)){int plus_index = str.find('+');int equal_index = str.find('=');a = string_to_int(str.substr(0, plus_index));b = string_to_int(str.substr(plus_index+2, equal_index-plus_index-2));if (a + b != 0){cout << a + b << endl;} else {break;}}return 0;}
0 0
- 九度OJ 题目1010:A + B
- 九度OJ-题目1010:A + B
- 九度 题目1010:A + B
- 九度OJ 题目1010:A + B
- 九度OJ-题目1010:A+B
- 九度OJ:题目1010 A+B
- 九度 oj 题目1010:A + B
- 九度OJ-题目1010 A + B
- 题目1010:A + B 九度OJ
- 九度OJ—题目1010:A + B
- 题目 1010 A + B 九度Online Judge
- a+b (九度oj 题目60)
- 【九度】题目1000:计算a+b
- 【九度】题目1003:A+B
- 九度OJ 题目1003:A+B
- 九度OJ题目1003:A+B
- 九度online:题目1003:A+B
- 九度题目1015:还是A+B
- 三分法与二分法的区别和三分法总结
- 【分享】VNR翻译日语游戏汉化简易图解教材
- 如何高效利用GitHub
- Apache2建立虚拟主机
- EL表达式详细教程
- 九度 题目1010:A + B
- javah命令使用记录
- Git与Github入门资料
- [BZOJ 3791] 作业 · 动态规划
- llvm-clang和llvm-gcc
- 使用 Java 实现 Comet 风格的 Web 应用
- Android APK反编译查看源码及资源文件
- 模拟真实物体运动的js动画库插件-Anima
- c# 中值类型和引用类型