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<bits/stdc++.h>
#define one 1
#define two 2
#define three 3
#define four 4
#define five 5
#define six 6
#define seven 7
#define eight 8
#define nine 9
#define zero 0
using namespace std;
char a[];
int i=;
int t=;
int num[];
int con=;
int flag=;
int main()
{ while(scanf("%c",&a[i])){
if(a[i]>='a'&&a[i]<='z')
{
con++;
i++;
}
else if(a[i]=='+') {i++;flag =t;}
else if(a[i]!='=')
{ if(con==)
{
if(a[i-]=='o'&&a[i-]=='n') num[t++]=;
else if(a[i-]=='t'&&a[i-]=='w') num[t++]=;
else if(a[i-]=='s') num[t++]=;
}
else if(con==)
{
if(a[i-]=='u') num[t++]=;
else if(a[i-]=='v') num[t++]=;
else if(a[i-]=='n') num[t++]=;
else if(a[i-]=='r') num[t++]=;
}
else if(con==)
{
if(a[i-]=='e') num[t++]=;
else if(a[i-]=='n') num[t++]=;
else if(a[i-]=='t') num[t++]=;
}
con=;
i++;
}
else if(a[i]=='=')
{
if(num[]==num[]&&num[]==) return ;
if(t==) cout<<num[]+num[]<<endl;
else if(t==&&flag==) cout<<num[]*+num[]+num[]<<endl;
else if(t==&&flag==) cout<<num[]+num[]*+num[]<<endl;
else cout<<num[]*+num[]+num[]*+num[]<<endl;
memset(a,NULL,sizeof(a));
i=;
con=;
memset(num,NULL,sizeof(num));
t=;
flag=;
} }
}
 
 
 
 
 

hdu 1228的更多相关文章

  1. hdu 1228 A + B

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1228 A + B Description 读入两个小于100的正整数A和B,计算A+B.需要注意的是: ...

  2. 题解报告:hdu 1228 A+B(字符串)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1228 Problem Description 读入两个小于100的正整数A和B,计算A+B. 需要注意 ...

  3. 【HDU 1228】A + B

    题 Description 读入两个小于100的正整数A和B,计算A+B. 需要注意的是:A和B的每一位数字由对应的英文单词给出.    Input 测试输入包含若干测试用例,每个测试用例占一行,格式 ...

  4. hdu 1228 A+B 字符串处理 超级大水题

    中文意思不解释. 很水,我本来想用switch处理字符串,然后编译不通过...原来switch只能处理整数型的啊,我都忘了. 然后就有了很挫的一大串if代码了... 代码: #include < ...

  5. HDU 1228 A + B 浙江大学研究生冠军

    Problem Description 读入两个小于100的正整数A和B,计算A+B. 须要注意的是:A和B的每一位数字由相应的英文单词给出.   Input 測试输入包括若干測试用例,每一个測试用例 ...

  6. HDU 1228(字符串处理)

    题意是将所给算式求出结果. 用的方法非常麻烦,开始没考虑到零也需要处理,以为遇上零直接跳过即可,知道发现零可以占位,比如 one zero 值为 10 而不是 1…… 代码如下: #include & ...

  7. HDU 1228 字符串到数字的转化

    一道水题,练练字符串的输入输出 #include <cstdio> #include <cstring> using namespace std; ] , s2[]; int ...

  8. HDU 1698 & UESTC 1228 Just a hook

    算是线段树中的一道水题了,必须用到懒操作,否则会超时.或者也可以刚开始不计算和,只更新节点,最后算整个线段的颜色和. 1.懒操作法 /* 908ms 3448KB in HDU OJ*/ #inclu ...

  9. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

随机推荐

  1. 【原创】express3.4.8源码解析之路由中间件

    前言 注意:旧文章转成markdown格式. 跟大家聊一个中间件,叫做路由中间件,它并非是connect中内置的中间件,而是在express中集成进去的. 显而易见,该中间件的用途就是 ------ ...

  2. ReactJS入门学习一

    ReactJS入门学习一 阅读目录 React是什么? React如何制作组件? 理解组件属性props 理解页面中如何渲染数据的 理解从服务器端获取数据及理解state的 回到顶部 React是什么 ...

  3. mysql查询在一张表不在另外一张表的记录

    mysql查询在一张表不在另外一张表的记录   问题:    查询一个表(tb1)的字段记录不在另一个表(tb2)中      条件:tb1的字段key的值不在tbl2表中      -------- ...

  4. html 特殊字符 fmt table A

    html 特殊字符 “&”表示“&” “ ”表示空格 <fmt:bundle basename=""> basename制定配置文件的文件名,无须扩展名 ...

  5. NGUI 学习笔记实战——制作商城UI界面

    http://www.cnblogs.com/chongxin/p/3876575.html Unity3D的uGUI听说最近4.6即将推出,但是目前NGUI等UI插件大行其道并且已经非常成熟,所以我 ...

  6. vim中的查找和替换

    (文章是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 查找: Gsearch -F 'aa' -R  --include=*rb 替换: (1)在查找结果 ...

  7. 删除右键ATI CATALYST(R) Control Center的方法

    http://share.weiyun.com/c47530d3e44ea15b606d4ba6f1b00a28

  8. A desmos graph supersampling test

  9. 【GoLang】GoLang fmt 占位符详解

    golang 的fmt 包实现了格式化I/O函数,类似于C的 printf 和 scanf. # 定义示例类型和变量 type Human struct { Name string } var peo ...

  10. spring事物传播属性

    PROPAGATION_REQUIRED Support a current transaction; create a new one if none exists.  支持一个当前事务;如果不存在 ...