hdu/hdoj 1075 What Are You Talking About
2013-08-29 15:33
423 查看
stl 中的map容器,确立了一对一的关系;
#include <iostream>
#include <string>
#include <map>
using namespace std;
string words,temp;
map < string , string > mp;
int main ()
{
cin >> words;
while ( cin >> words, words != "END" )
{
cin >> temp;
mp[ temp ] = words;
}
cin >> words;
cin.get();
while ( getline ( cin, words ) && words != "END" )
{
string out = "";
int len = words.size();
for ( int i = 0; i != len; ++ i )
{
if ( isalpha ( words[i] ) )
{
out += words[i];
}
else
{
if ( mp[out] == "" )
cout << out;
else
cout << mp[out];
cout << words[i];
out = "";
}
}
cout << endl;
}
return 0;
}
#include <iostream>
#include <string>
#include <map>
using namespace std;
string words,temp;
map < string , string > mp;
int main ()
{
cin >> words;
while ( cin >> words, words != "END" )
{
cin >> temp;
mp[ temp ] = words;
}
cin >> words;
cin.get();
while ( getline ( cin, words ) && words != "END" )
{
string out = "";
int len = words.size();
for ( int i = 0; i != len; ++ i )
{
if ( isalpha ( words[i] ) )
{
out += words[i];
}
else
{
if ( mp[out] == "" )
cout << out;
else
cout << mp[out];
cout << words[i];
out = "";
}
}
cout << endl;
}
return 0;
}
相关文章推荐
- HDU/HDOJ 1075 What Are You Talking About(字典树|STL map)
- hdoj1075 What Are You Talking About(STL map处理字符串)
- HDOJ 1075 -- What Are You Talking About Trie( STL )
- HDOJ 1075 What Are You Talking About
- hdoj 1075 What Are You Talking About 【STL map+string】
- [HDOJ1075]What Are You Talking About
- hdoj1075 What Are You Talking About
- HDOJ 1075 (What Are You Talking About)
- HDOJ 1075 What Are You Talking About
- Hdoj 1075 What Are You Talking About 【MAP】
- HDOJ 1075 What are you talking about ? 字典树
- 【HDOJ】1075 What Are You Talking About
- [HDOJ]problem_1075【What Are You Talking About】
- HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)
- hdoj--1075 What Are You Talking About(Trie or map)
- HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)
- HDOJ 1075 What Are You Talking About(字典树)
- HDOJ 1075 What are you talking about (map + 字符串 )
- HDOJ.1075 What Are You Talking About(map)
- ACM--火星文--HDOJ 1075--What Are You Talking About--map