Description

         读入两个小于100的正整数A和B,计算A+B.       
         需要注意的是:A和B的每一位数字由对应的英文单词给出.        
                

Input

测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B =",相邻两字符串有一个空格间隔.当A和B同时为0时输入结束,相应的结果不要输出.        
                

Output

对每个测试用例输出1行,即A+B的值.        
                

Sample Input

one + two =
three four + five six =
zero seven + eight nine =
zero + zero =
                

Sample Output

3 90 96
 
#include <iostream>
#include <string>
using namespace std;
int g(string str)
{
if(str=="zero")return ;
if(str=="one")return ;
if(str=="two")return ;
if(str=="three")return ;
if(str=="four")return ;
if(str=="five")return ;
if(str=="six")return ;
if(str=="seven")return ;
if(str=="eight")return ;
if(str=="nine")return ;
}
int main()
{
string a[];
while(cin>>a[]>>a[]>>a[]){
int i,k1,k2;
for(i=;;i++){
cin>>a[i];
if(a[i]=="=")break;
}
if(a[]=="zero"&&a[]=="+"&&a[]=="zero"&&a[]=="=")break;
if(a[]=="+"){
k1=g(a[]);
if(a[]=="=")k2=g(a[]);
else k2=g(a[])*+g(a[]);
}
else{
k1=*g(a[])+g(a[]);
if(a[]=="=")k2=g(a[]);
else k2=g(a[])*+g(a[]);
}
cout<<k1+k2<<endl;
}
//system("pause");
return ;
}

依旧灵活使用字符串即可

 
 

P - A + B(第二季水)的更多相关文章

  1. F - The Fun Number System(第二季水)

    Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...

  2. D - Counterfeit Dollar(第二季水)

    Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...

  3. S - 骨牌铺方格(第二季水)

    Description          在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.         例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...

  4. R - 一只小蜜蜂...(第二季水)

    Description          有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数.         其中,蜂房的结构如下所示.     ...

  5. I - Long Distance Racing(第二季水)

    Description Bessie is training for her next race by running on a path that includes hills so that sh ...

  6. Y - Design T-Shirt(第二季水)

    Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...

  7. N - Robot Motion(第二季水)

    Description A robot has been programmed to follow the instructions in its path. Instructions for the ...

  8. B - Maya Calendar(第二季水)

    Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old ...

  9. T - 阿牛的EOF牛肉串(第二季水)

    Description          今年的ACM暑期集训队一共有18人,分为6支队伍.其中有一个叫做EOF的队伍,由04级的阿牛.XC以及05级的COY组成.在共同的集训生活中,大家建立了深厚的 ...

  10. E - Number Sequence(第二季水)

    Description A single positive integer i is given. Write a program to find the digit located in the p ...

随机推荐

  1. 判断两个View的GRect是否相等

    if (CGRectEqualToRect(self.view.frame, rect)) { // do some stuff }

  2. [转]PictureEx.h和PictureEx.cpp源文件

    要显示一个gif,网上找了个,子类化了MFCl图片控件,用着方便,记一下 转自:http://www.bccn.net/Article/net/vcnet/jszl/200709/6386.html ...

  3. js的原型继承小结

    考虑:有一个想要复用的对象,并且想要创建的第二个对象需要从第一个对对象中获取其功能. 实现如下: //要继承的对象 var parent = { name:"Papa" }; // ...

  4. Windows10 磁盘活动时间百分之百导致系统卡顿解决方法

    最近电脑边的特别慢,打开任务管理器发现是磁盘活动时间时不时的就会变成100%.起初是以为硬盘出问题了,后来网上查了一下才发现很多人都遇到过这个问题,其原因就是Windows的SuperFetch和家庭 ...

  5. php在cli和cgi方式下获取服务器ip的实例

    php cli方式下获取服务器ip php内核没有提供这样的命令,需要借助linux中的命令ifconfig来实现,如下两个函数代码: function getServerIp(){          ...

  6. 用php逐行读取文件

    做个备份年纪大了,都不愿意自己思考了 $str = file_get_contents($tmpfilename);//获得内容 $arr = explode("\n",$str) ...

  7. postgresql配置的一些问题

    ubuntu通过软件中心安装后,配置文件位于如下目录 我用超级用户创建了其它数据库用户,发现是登录不了的,必须还得创建同名的linux用户,甚是麻烦.在配置文件pg_hba.conf中发现了问题. 其 ...

  8. mysql innodb_double_write特性

    知识储备: 1.mysql 的crasy recovery 是通过redo log 和undo log 来完成的: 2.redo log 和undo log的记录的是对页面的物理操作:如在1024号p ...

  9. 添加事件监听兼容IE6-8

    IE8一下浏览器不支持addEventListener,用attachEvent取而代之,但是在时间类型前面要加上’on‘,例如click时间在attachEvent中要写成onclick. var ...

  10. mongodb操作记录

    [User]1.db.addUser("name","pwd","true/false")2.db.auth("name" ...