hdu 1075 What Are You Talking About(给你字典,让你翻译句子,字典中查不到的单词不用翻译)
来源:互联网 发布:单片机原理及应用林立 编辑:程序博客网 时间:2024/05/16 07:36
1.这是一道字典树的题,但用map也可以做
2.代码:
#include<cstdio>#include<cstring>#include<iostream>#include<map>using namespace std;map<string,string> mp;char s[30100],ss[15];int main(){ scanf("%s",s); while(1) { scanf("%s",s); if(strcmp(s,"END")==0) break; scanf("%s",ss); string s1,s2; int len1=strlen(s); int len2=strlen(ss); for(int i=0; i<len1; i++) { s1+=s[i]; } for(int i=0; i<len2; i++) { s2+=ss[i]; } mp.insert(make_pair(s2,s1)); } map<string,string>::iterator it; /*for(it=mp.begin();it!=mp.end();it++) { cout<<(it->first)<<" "<<(it->second)<<endl; }*/ scanf("%s",s); getchar(); while(1) { gets(s); //getchar(); if(strcmp(s,"END")==0) { break; } int len=strlen(s); //s[len]=' '; string sss; for(int i=0; i<=len; i++) { if(s[i]>=97&&s[i]<=122) { sss+=s[i]; } else { if(sss.size()==0) { if(i!=len) cout<<s[i]; continue; } else { it=mp.find(sss); if(it!=mp.end()) { cout<<it->second; } else { cout<<sss; } if(i!=len) cout<<s[i]; sss.clear(); } } } cout<<endl; } return 0;}
0 0
- hdu 1075 What Are You Talking About(给你字典,让你翻译句子,字典中查不到的单词不用翻译)
- hdu 1075 What Are You Talking About (字典树·文字翻译)
- HDU 1075 What Are You Talking About(字典树)
- hdu 1075 What Are You Talking About (字典树)
- hdu-1075-What Are You Talking About-(字典树)
- hdu 1075 What Are You Talking About(字典树方法)
- hdu 1075 What Are You Talking About 字典树
- HDU 1075 What Are You Talking About 字典树
- hdu 1075 What Are You Talking About(字典树)
- hdu 1075 What Are You Talking About(字典树)
- hdu 1075 What Are You Talking About (字典树)
- hdu 1075 What Are You Talking About 字典树
- hdu 1075 What Are You Talking About(字典树)
- [字典树] HDU 1075 - What Are You Talking About
- hdu 1075 What Are You Talking About 字典树 trie
- hdu 1075 What Are You Talking About (字典树)
- hdu 1075 What Are You Talking About 字典树
- HDU 1075 What Are You Talking About(字典树)
- UIStoryboardSegue(多控制器)
- 怎么查看你的Win7或者Win8.1的授权方式
- 跳跳 (BFS) CUS 1259
- 【算法总结--数组相关】双指针法的常见应用。
- UITabBarController
- hdu 1075 What Are You Talking About(给你字典,让你翻译句子,字典中查不到的单词不用翻译)
- iOS入门(二十五)基础控件
- Jenkins + GitHub + fir-cli 一行命令从源码到 fir.im
- Quartz2D
- Linux设备驱动开发学习步骤
- 注解 @Resource
- 【算法总结-数组相关】 数组中找特定元素相关~
- vmware workstation 11 安装RAC第二问
- 优化算法——截断梯度法(TG)