【HDOJ】1075 What Are You Talking About
2014-04-02 17:08
387 查看
map,STL搞定。
#include <iostream> #include <string> #include <cstdio> #include <cstring> #include <map> using namespace std; #define MAXN 3005 char buf[MAXN], word[15]; int main() { map<string, string> dict; map<string, string>::iterator it; int i, j; scanf("%*s"); // START while (scanf("%s", buf)!=EOF && strcmp(buf, "END")) { scanf("%s", word); dict[word] = buf; } scanf("%*s%*c"); // START while (gets(buf)!=NULL && strcmp(buf, "END")) { for (i=0, j=0; i<strlen(buf); ++i) { if (buf[i]>='a' && buf[i]<='z') { word[j++] = buf[i]; } else { // If there is a valid word, find in dict. if (j) { word[j++] = '\0'; // add '\0' it = dict.find(word); if (it != dict.end()) printf("%s", (*it).second.data()); else printf("%s", word); j = 0; } printf("%c", buf[i]); } } printf("\n"); } return 0; }
相关文章推荐
- hdoj1075 What Are You Talking About(STL map处理字符串)
- hdoj 1075 What Are You Talking About 【STL map+string】
- HDOJ 1075 What Are You Talking About(trie树入门)
- HDU/HDOJ 1075 What Are You Talking About(字典树|STL map)
- HDOJ 1075 What Are You Talking About
- [HDOJ1075]What Are You Talking About
- HDOJ 1075 -- What Are You Talking About Trie( STL )
- hdoj1075 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 1075 (What Are You Talking About)
- hdoj--1075 What Are You Talking About(Trie or map)
- HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)
- [HDOJ]problem_1075【What Are You Talking About】
- 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