博客
关于我
one + two = 3
阅读量:395 次
发布时间:2019-03-05

本文共 1134 字,大约阅读时间需要 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 =

样例输出

39096
#include 
#include
#include
using namespace std;int to(string str){ if(str=="one") return 1; else if(str=="two") return 2; else if(str=="three") return 3; else if(str=="four") return 4; else if(str=="five") return 5; else if(str=="six") return 6; else if(str=="seven") return 7; else if(str=="eight") return 8; else if(str=="nine") return 9; else if(str=="zero") return 0; else return 0; } 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)*10+to(b); sin>>b; } sin>>c>>d; if(d=="=") n=to(c); else { n=to(c) * 10 + to(d); } if(n == 0&&m == 0) break; cout<
<

 

转载地址:http://zawkz.baihongyu.com/

你可能感兴趣的文章
apache虚拟主机配置
查看>>
光盘作为yum源
查看>>
PHP 正则表达式资料
查看>>
PHP官方网站及PHP手册
查看>>
mcrypt加密以及解密过程
查看>>
mysql连续聚合
查看>>
go等待N个线程完成操作总结
查看>>
消息队列 RocketMQ 并发量十万级
查看>>
ReactJs入门教程-精华版
查看>>
乐观锁悲观锁应用
查看>>
Window环境下安装Redis 并 自启动Redis 及 Redis Desktop Manager
查看>>
.net Core 使用IHttpClientFactory请求
查看>>
多线程之旅(准备阶段)
查看>>
Python 之网络式编程
查看>>
MySql5.5安装步骤及MySql_Front视图配置
查看>>
mybatis绑定错误-- Invalid bound statement (not found)
查看>>
mybatis #{}和${}区别
查看>>
Java Objects工具类重点方法使用
查看>>
Java内存模型(JMM)
查看>>
AQS相关
查看>>