one + two = 3
读入两个小于100的正整数A和B,计算A+B。需要注意的是:A和B的每一位数字由对应的英文单词给出。
输入
测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B =",相邻两字符串有一个空格间隔。当A和B同时为0时输入结束,相应的结果不要输出。
输出
对每个测试用例输出1行,即A+B的值。
样例输入
one + two =
three four + five six =
zero seven + eight nine =
zero + zero =
样例输出
3
90
96
#include <iostream>
#include <string>
#include <sstream>
using namespace std; int to(string str){
if(str=="one") return ;
else if(str=="two") return ;
else if(str=="three") return ;
else if(str=="four") return ;
else if(str=="five") return ;
else if(str=="six") return ;
else if(str=="seven") return ;
else if(str=="eight") return ;
else if(str=="nine") return ;
else if(str=="zero") return ;
else return ;
}
int main()
{
string a,b,c,d,e;
int m,n;
string s;
while(getline(cin,s))
{
stringstream sin(s);
sin>>a>>b;
if(b=="+")
{
m=to(a);
}
else
{
m=to(a)*+to(b);
sin>>b;
}
sin>>c>>d;
if(d=="=")
n=to(c);
else { n=to(c) * + to(d);
}
if(n == &&m == ) break;
cout<<m+n<<endl; }
return ;
}
随机推荐
- cenos云服务器搭建虚拟主机
---恢复内容开始--- vim基本操作 1.如果apache安装成为Linux的服务的话,可以用以下命令操作: service httpd start 启动 service httpd restar ...
- jQuery的ajax实现文件上传大小限制
用jquery的ajax实现简单的文件上传功能,并且限制文件大小,先上代码. <!DOCTYPE html> <html> <head> <meta char ...
- java web 简单的权限管理
spring ,springMvc ,mybatis 简单权限管理 其实只需要3张表..admin_group ,function,group 表
- input keyup的时候实现内容过滤
当在文本框中输入关键字,就会搜索出包含关键字的数据 实现: 只需要一个内容过滤即可 <body> <input type="text" id="sear ...
- Laravel5.1 目录结构解析
学习一门框架,首先要了解的就是目录结构.对目录结构清晰就可以着手学习了~这里不作新特性的介绍,权当目录结构手册看吧.若发现有何不恰当的地方请联系我哦~注:写本文时参照的是5.1.4版本 目录或文件 说 ...
- 安装openstack时遇到的错误
学习opensatck的第一步是安装DevStack来进行本机操作 1. 下面命令没有权限,解决办法:切换到root用户下执行sudo -s echo "stack ALL=(ALL) NO ...
- ubuntu中误删/var/lib/dpkg/info的补救方法
今晚在ubuntu上安装一个软件时,出现这样的错误提示:E: Sub-process /usr/bin/dpkg returned an error code (1)然后在网上找了查找问题原因及解决方 ...
- python3 杂记
python3 杂记 test001 --test001.py ( from test2.test002 import * def test1(): print('1') if __nam ...
- Electron、Node.js、JavaScript、JQuery、Vue.js、Angular.js,layui,bootstrap
转载:https://blog.csdn.net/meplusplus/article/details/79033786 layui :是基于jquery库的封装开发. bootstrap:同样基于 ...
- gulp不压缩打包layui
从网上下载的layui都是压缩包,如何打包在一个文件且不压缩呢?如下方法: 1.https://gitee.com/sentsin/layui下载源码(本文的为2.4.5版本) 2.安装nodejs( ...