hdu 1228
Description
需要注意的是:A和B的每一位数字由对应的英文单词给出.
Input
Output
Sample Input
three four + five six =
zero seven + eight nine =
zero + zero =
Sample Output
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的更多相关文章
- hdu 1228 A + B
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1228 A + B Description 读入两个小于100的正整数A和B,计算A+B.需要注意的是: ...
- 题解报告:hdu 1228 A+B(字符串)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1228 Problem Description 读入两个小于100的正整数A和B,计算A+B. 需要注意 ...
- 【HDU 1228】A + B
题 Description 读入两个小于100的正整数A和B,计算A+B. 需要注意的是:A和B的每一位数字由对应的英文单词给出. Input 测试输入包含若干测试用例,每个测试用例占一行,格式 ...
- hdu 1228 A+B 字符串处理 超级大水题
中文意思不解释. 很水,我本来想用switch处理字符串,然后编译不通过...原来switch只能处理整数型的啊,我都忘了. 然后就有了很挫的一大串if代码了... 代码: #include < ...
- HDU 1228 A + B 浙江大学研究生冠军
Problem Description 读入两个小于100的正整数A和B,计算A+B. 须要注意的是:A和B的每一位数字由相应的英文单词给出. Input 測试输入包括若干測试用例,每一个測试用例 ...
- HDU 1228(字符串处理)
题意是将所给算式求出结果. 用的方法非常麻烦,开始没考虑到零也需要处理,以为遇上零直接跳过即可,知道发现零可以占位,比如 one zero 值为 10 而不是 1…… 代码如下: #include & ...
- HDU 1228 字符串到数字的转化
一道水题,练练字符串的输入输出 #include <cstdio> #include <cstring> using namespace std; ] , s2[]; int ...
- HDU 1698 & UESTC 1228 Just a hook
算是线段树中的一道水题了,必须用到懒操作,否则会超时.或者也可以刚开始不计算和,只更新节点,最后算整个线段的颜色和. 1.懒操作法 /* 908ms 3448KB in HDU OJ*/ #inclu ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
随机推荐
- Unity3d与iOS交互开发——接入平台SDK必备技能
原地址:http://www.2cto.com/kf/201401/273337.html# 前言废话:开发手机游戏都知道,你要接入各种平台的SDK.那就需要Unity3d与iOS中Objective ...
- svn提交时强制添加注释 (转)
SVN提交时,如果没有注释,在查阅历史时,会非常不方便.因此我们需要有一个让程序员提交代码时,强制添加注释的规则.下面看看在SVN中怎么实现. 1. 推荐使用VisualSVN作为服务端(免费下载地址 ...
- Leetcode 之Construct Binary Tree(52)
根据先序和中序构造二叉树.根据中序和后序构造二叉树,基础题,采用递归的方式解决,两题的方法类似.需要注意的是迭代器的用法. //先序和中序 TreeNode *buildTree(vector< ...
- LBP
参考:http://www.cnblogs.com/mikewolf2002/p/3438698.html
- make_head,,,pop_head,,,push_head,,,sort_head..
STL中,有很多的排序函数模板供我们调用,省去我们自己编写一些排序过程的麻烦.本文是一篇关于STL中堆排序的一个介绍. 本文涉及的几个函数如下:make_heap(), push_heap(), po ...
- python中import和from...import...的区别
python中import和from...import...的区别: 只用import时,如import xx,引入的xx是模块名,而不是模块内具体的类.函数.变量等成员,使用该模块的成员时需写成xx ...
- 【leetcode】String to Integer (atoi)
String to Integer (atoi) Implement atoi to convert a string to an integer. Hint: Carefully consider ...
- Windows命令行重命名文件
RENAME D:\Cache\xyz.html xyz%date:~0,4%%date:~5,2%%date:~8,2%.tar.gz
- cocos2dx混合模式应用
//Opacity 0完全透明 255完全不透明 //ALPHA 0完全透明 1完全不透明 CCRenderTexture* pRT = CCRenderTexture::create(480,320 ...
- codeforces 475A.Bayan Bus 解题报告
题目链接:http://codeforces.com/problemset/problem/475/A 题目意思:输入一个整数 k(0 ≤ k ≤ 34),表示participants的人数,需要在一 ...