A + B

点我挑战题目

点我一起学习STL-MAP

题意分析

讲字符串和数字用map对应即可

代码总览

/*
Title:HDOJ.1228
Author:pengwill
Date:2016-11-21
*/
#include <iostream>
#include <map>
#include <string>
using namespace std;
typedef map<string,int> mmp;
mmp p;
mmp::iterator iter1,iter2,iter3; string s1,s2,s3,s4,s5,s6;
int main()
{
cin.sync_with_stdio(false);
cin.tie(0);
p["zero"] = 0;
p["one"] = 1;
p["two"] = 2;
p["three"] = 3;
p["four"] = 4;
p["five"] = 5;
p["six"] = 6;
p["seven"] = 7;
p["eight"] = 8;
p["nine"] = 9;
while(cin>>s1>>s2>>s3){
if(s2.compare("+") == 0){
if(s1.compare("zero")==0 && s3.compare("zero")==0){
break;
}else{
cin>>s4;
if(s4.compare("=") == 0){
iter1 = p.find(s1);iter2 = p.find(s3);
cout<<iter1->second + iter2->second<<endl;
}else{
int a;
cin>>s5;
iter3 = p.find(s1);
iter1 = p.find(s3);iter2 = p.find(s4);
a = iter1->second * 10 + iter2->second;
cout<<a+ iter3->second <<endl;
} }
}else{
int a,b;
iter1 = p.find(s1);iter2 = p.find(s2);
a = iter1->second * 10 + iter2->second;
cin>>s1>>s2;
if(s2.compare("=") == 0){
// cout<<s2<<endl;
iter3 = p.find(s1);
b = iter3->second;
// cout<<s1<<endl;
// cout<<iter3->second<<endl;
cout<<a + b<<endl;;
}else{
cin>>s3;
iter1 = p.find(s1);iter2 = p.find(s2);
b = iter1->second * 10 + iter2->second;
cout<<a+b<<endl;
} }
} return 0;
}

HDOJ.1228 A + B (map)的更多相关文章

  1. HDOJ.1263 水果(map)

    水果 点我跳转到题面 点我一起学习STL-MAP 题意分析 给出多组测试数据,每组数据有多条信息.分别是水果种类,地点,和水果数目.每组信息要按照样例输出,并且输出要按照地点->水果种类的字典序 ...

  2. hdoj 1251 字典树||map

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  3. HDOJ.1800 Flying to the Mars(贪心+map)

    Flying to the Mars 点我挑战题目 题意分析 有n个人,每个人都有一定的等级,高等级的人可以教低等级的人骑扫帚,并且他们可以共用一个扫帚,问至少需要几个扫帚. 这道题与最少拦截系统有异 ...

  4. HDOJ.1113 Word Amalgamation(map)

    Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...

  5. HDOJ.2072 单词数(map)

    单词数 点我挑战题目 点我一起学习STL-MAP 题意分析 给出一行单词,判断这行有不同种的单词多少个,用map可以轻松解决. 代码总览 /* Title:HDOJ.2072 Author:pengw ...

  6. HDOJ.2094 产生冠军(map)

    产生冠军 点我挑战题目 点我一起学习STL-MAP 题意分析 给出n组数据,代表a打败了b,让判断根据这n组数据是否能判断出来产生了冠军.一开始以为这道题很难,其实用map可以应付. 大原则,赢了的人 ...

  7. HDOJ.1075 What Are You Talking About(map)

    What Are You Talking About 点我跳转到题面 点我一起学习STL-MAP 题意分析 首先第一组START-END给出翻译的字典,第二组START-END给出一句话,查找里面出现 ...

  8. HDOJ.1029 Ignatius and the Princess IV(map)

    Ignatius and the Princess IV 点我跳转到题面 点我一起学习STL-MAP 题意分析 给出一个奇数n,下面有n个数,找出下面数字中出现次数大于(n+1)/2的数字,并输出. ...

  9. HDOJ/HDU 1251 统计难题(字典树啥的~Map水过)

    Problem Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己 ...

随机推荐

  1. VMware 15.0下载及安装教程

    虚拟机 VMware WorkStation Pro15 下载及安装详细解 9虚拟机 VMware WorkStation Pro15 下载及安装详细解. 虚拟机官方网站: https://www.v ...

  2. 推荐:一个适合于Python新手的入门练手项目

    随着人工智能的兴起,国内掀起了一股Python学习热潮,入门级编程语言,大多选择Python,有经验的程序员,也开始学习Python,正所谓是人生苦短,我用Python 有个Python入门练手项目, ...

  3. Java and SDK 环境变量设置

    File comes from http://www.cnblogs.com/shinge/p/5500002.html JAVA环境变量配置详解 JAVA环境变量JAVA_HOME.CLASSPAT ...

  4. TW实习日记:第29-30天

    这两天挺忙,赶工期,改bug.项目现场的同事说客户火大得不行.可是谁叫你们谈工期谈的这么紧,完全不考虑开发的情况,真的是烦人这种事情.这两天遇到的最有难度的一个点就是附件预览,搞这个改到晚上11点. ...

  5. python常用命令—‘\r’

    # \r 默认表示将输出的内容返回到第一个指针,这样的话,后面的内容会覆盖前面的内容 如常用的显示程序完成进度!!

  6. [leetcode-783-Minimum Distance Between BST Nodes]

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...

  7. 业务迁移---web

    #本文是做记录使用,不做为任何参考文档# 迁移代码 将源代码scp至新的server上 搭建服务 yum安装nginx服务 yum install nginx #yum安装 service nginx ...

  8. ViewPager的简单使用说明

    前提:工程中使用ViewPager,需要导入google提供的jar包(android-support-v4.jar). 要学习ViewPager的使用,建议直接看官方文档 Creating Swip ...

  9. Memory及其controller芯片整体测试方案(上篇)

    如果你最近想买手机,没准儿你一看价格会被吓到手机什么时候偷偷涨价啦! 其实对于手机涨价,手机制造商也是有苦难言,其中一个显著的原因是存储器芯片价格的上涨↗↗↗ >>> 存储器memo ...

  10. Spring Security 快速了解

    在Spring Security之前 我曾经使用 Interceptor 实现了一个简单网站Demo的登录拦截和Session处理工作,虽然能够实现相应的功能,但是无疑Spring Security提 ...