1. 程式人生 > >hdu 1075 What Are You Talking About STL的使用

hdu 1075 What Are You Talking About STL的使用

STL 的map容器使用

題意:給你一些單詞的對應表,然後給你一些句子,輸出句子,並把句子中與單詞對應表中相對應的單詞輸出

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;
map<string,string> mp;
int main()
{
    string s1,s2;
    map<string,string>::iterator iter;
    char ch;
    while(cin>>s1)
    {
        mp.clear();
        while(true)
        {
            cin>>s1;
            if(s1=="END")break;
            cin>>s2;
            mp[s2]=s1;
        }
        cin>>s1;
        getchar();
        while(true)
        {
            s2="";
            while(scanf("%c",&ch)!=EOF)
            {
                if(ch=='\n'&&s2=="END") return 0;
                if(ch=='\n') break;
                if(!isalpha(ch))
                {
                    iter=mp.find(s2);
                    if(iter!=mp.end())cout<<iter->second;
                    else
                        cout<<s2;
                    cout<<ch;
                    s2="";
                }
                else s2+=ch;
            }
            printf("\n");
        }
    }
    return 0;
}



相關推薦

hdu 1075 What Are You Talking About STL的使用

STL 的map容器使用 題意:給你一些單詞的對應表,然後給你一些句子,輸出句子,並把句子中與單詞對應表中相對應的單詞輸出 #include<stdio.h> #include<stdlib.h> #include<string.h>

HDU 1075 What Are You Talking About(map或字典樹)

dict cout you als next times pre word selected What Are You Talking About Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400

hdu 1075 What Are You Talking About (map)

std when mars some tchar code hdu mar cep What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/20480

HDU 1075.What Are You Talking About【Map水題(字典樹)】【5月25】

What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others) Total Submission(s): 1

HDU 1075 What Are You Talking About(經典字典樹)

Problem Description Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian g

HDU 1072 What Are You Talking About

分類 HDU map STL 題意 給出一個“翻譯-原文”的對應表,然後給出句子,要把句子中的原文都翻譯出來。 樣例輸入輸出 Sample Input START from fiwo hello difh mars riwosf earth fn

What Are You Talking About (map)

stream out pan rec () start end contains his Ignatius is so lucky that he met a Martian yesterday. But he didn‘t know the language the Ma

HDU1075 What Are You Talking About(字典樹+映射)

void scan return 字符串 strlen ons 直接 esp strcmp http://acm.hdu.edu.cn/showproblem.php?pid=1075 題意沒什麽好說的,就是一個字典樹的查找。 這道題主要在於格式的輸出上,反正坑了我好久的!

What Are You Talking About HDU1075

字符 isp clu ace view 分享圖片 img getch col 一開始我也想用map 但是處理不好其他字符。。 看了題解 多多學習! 很巧妙 就是粗暴的一個字符一個字符的來 分為小寫字母和非小寫字母兩個部分 一但單詞結束的時候就開始判斷。 #in

Ask HN: What AI subtopic are you excited about?

Personally, I've been studying ML for the past few months, especially neuroscience inspired architectures, and I stumbled across https://en.wikipedia.org/w

what are you 弄啥嘞!!!!!!!!!!!!!!!!泛型

版本 exceptio 文章 泛型的使用 cat emp 轉換 cep 都是 1.為什麽需要泛型 泛型在Java中有很重要的地位,網上很多文章羅列各種理論,不便於理解,本篇將立足於代碼介紹、總結了關於泛型的知識。希望能給你帶來一些幫助。 先看下面的代碼: List l

what are you living for ?

本文主要闡明以下幾個問題: 1、Spring框架的作用 2、瞭解spring體系 3、為什麼選擇spring 一、spring框架的作用 先簡單瞭解下Spring的架構。 Spring以IOC和Core為基礎,向普通的開發者提供了依賴管理的能力 在此之上,S

Ask HN: What are you working on and why is it cool?

It's easy to get tunnel vision when you are heads down working on a project and it's easy to forget there are thousands of other people doing the same thin

Ask HN: Who here works in the IoT space and what are you doing?

I'm an FE dev at a start-up called Airfi Networks and we provide telecom services to companies which manufacture smart devices. I was wondering what other

Ask HN: What do you think about my agency's new website and how can I improve it

We had to retire our old website, and move to something more modern and simplistic. However i feel that i spent a lot of time over thinking this project, s

Ask HN: What are you currently working on in your spare time?

With the spread (...foo) operator you can already merge json objects. However in order to use it you need to have access to the objects you make reference

Ask HN: What are you favorite tiny tools?

Sure.Diary: - Python script that fetches the diary template and fills it with information like location - With x-callback-url it is sent to drafts - i

Ask HN: Are you thinking about investing in an Opportunity Zone?

Part of the Republican 2017 tax reform involved a section about Opportunity Zones. These are designated low-income areas where the government wishes to in

Ask HN: What do you hate about where you live?

I'll start. What I hate about NYC:1) Home- Apartments are expensive. Can get 4x more space in Chicago for same price.- Difficult to shop for home. Wanted a

Ask HN: What are you thankful for?

1. I can go into a grocery store and buy whatever I want without once thinking about the price of something or the total bill. It's an incredible privilege