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. ubuntu 快捷图标

    ubuntu的图标都存在 /usr/share/applications下 图标是Desktop的后缀 首先gedit /usr/share/applications/xx.Desktop xx为应用 ...

  2. UVA11361 Investigating Div-Sum Property(数位dp)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 题目意思:问在区间[A,B]有多少个数不仅满足自身是k的倍数,而且其各个位数上的和 ...

  3. css white-space

    以下是对上面几个属性的测试效果如下: 具体代码如下: <!DOCTYPE html> <html lang="en"> <head> <m ...

  4. BZOJ 1458 士兵占领

    http://www.lydsy.com/JudgeOnline/problem.php?id=1458 题意:n x m的棋盘,k个位置不能放,每行和每列都有要求至少的士兵,求能否有最少的满足条件的 ...

  5. USB Mass Storage学习笔记-STM32+FLASH实现U盘

    一.内容概述  采用STM32内部自带USB控制器外加大页NAND FLASH K9F1G08U0A实现一个128M的U盘. 1.STM32的USB控制器 STM32F103的MCU自带USB从控制器 ...

  6. Linux实现SSH无密码登录(对目录权限的设置非常详细,可以参考一下)

    假设服务器IP地址为192.168.1.1,机器名:cluster.hpc.org 客户端IP地址为172.16.16.1,机器名:p470-2.wangrx.sioc.ac.cn 客户端用户yzha ...

  7. UNIX网络编程---TCP客户/服务器程序示例(五)

    一.概述 客户从标准输入读入一行文本,并写给服务器 服务器从网络输入读入这行文本,并回射给客户 客户从网络输入读入这行回射文本,并显示在标准输出上 二.TCP回射服务器程序:main函数 这里给了函数 ...

  8. Unix/Linux环境C编程入门教程(31) 数学函数带你战胜企业面试

    1.函数介绍: abs()acos()asin()atan()atan2()ceil()cos()cosh()exp()frexp()ldexp()log()log10()pow()sin()sinh ...

  9. java中classPath和Xpath问题

    java中classPath和Xpath问题 今天遇到一个问题想获取classpath对应的目录,开始还以为java源代码可以像spring配置文件.xml中一样通过classpath:来获取对应的路 ...

  10. H.264 RTP 封包格式

    H.264 视频 RTP 负载格式 1. 网络抽象层单元类型 (NALU) NALU 头由一个字节组成, 它的语法如下: +---------------+      |0|1|2|3|4|5|6|7 ...