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. 已知TSP问题的最好解

    a280 : 2579ali535 : 202339att48 : 10628att532 : 27686bayg29 : 1610bays29 : 2020berlin52 : 7542bier12 ...

  2. Java 一个字符串在另外一个字符串出现次数

    统计一个字符串在另外一个字符串出现次数 代码如下: package me.chunsheng.javatest; import java.util.regex.Matcher; import java ...

  3. project euler 12 Highly divisible triangular number

    Highly divisible triangular number Problem 12 The sequence of triangle numbers is generated by addin ...

  4. C语言基础10

    栈区间:在函数内部声明的变量都存放在栈区间,比如int char 数组 结构体 指针,只管申请,系统会自动帮我们回收,收回的时间是作用域结束之后,遵循的原则是"先进后出". int ...

  5. #1042 - Can't get hostname for your address

    my.ini 或 my.cnf 末尾添加 skip-name-resolve 并重启MySQL服务器 ok!

  6. javacc

    http://www.cnblogs.com/Gavin_Liu/archive/2009/03/07/1405029.html https://javacc.java.net/ http://www ...

  7. C语言必背18个经典程序

    C语言必背18个经典程序 1./*输出9*9口诀.共9行9列,i控制行,j控制列.*/ #include "stdio.h" main() {int i,j,result; for ...

  8. 挑战以Dropbox为代表的传统“同步网盘”,Seafile推出“分布式文件同步技术”打造的私有云服务

    挑战以Dropbox为代表的传统“同步网盘”,Seafile推出“分布式文件同步技术”打造的私有云服务#36氪开放日# 其他 JasonZheng • 2012-04-07 15:14 来自36氪开放 ...

  9. 关于ArcGIS Rest API

    ArcGIS Rest API: 9.3版本: http://resources.esri.com/help/9.3/arcgisserver/apis/rest/index.html 10版本:ht ...

  10. JAVA的类加载器,详细解释

    JVM规范定义了两种类型的类装载器:启动内装载器(bootstrap)和用户自定义装载器(user-defined class loader). 一. ClassLoader基本概念 1.ClassL ...