Compound Words
来源:互联网 发布:农业数据库 编辑:程序博客网 时间:2024/06/08 02:05
You are to find all the two-word compound words in a dictionary. A two-word compound word is a
word in the dictionary that is the concatenation of exactly two other words in the dictionary.
Input
Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will
be no more than 120,000 words.
Output
Your output should contain all the compound words, one per line, in alphabetical order.
Sample Input
a
alien
born
less
lien
never
nevertheless
new
newborn
the
zebra
Sample Output
alien
word in the dictionary that is the concatenation of exactly two other words in the dictionary.
Input
Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will
be no more than 120,000 words.
Output
Your output should contain all the compound words, one per line, in alphabetical order.
Sample Input
a
alien
born
less
lien
never
nevertheless
new
newborn
the
zebra
Sample Output
alien
newborn
#include <iostream>#include <cstdio>#include <cstring>#include <set>using namespace std;set <string> a;int main(){ string s,s1,s2; set <string>::iterator it; while(cin>>s) a.insert(s); for(it=a.begin();it!=a.end();it++){ s=*it; for(int i=0;i<s.length()-1;i++) { s1=s.substr(0,i+1); s2=s.substr(i+1,s.length()-(i+1)); if(a.find(s1)!=a.end()&&a.find(s2)!=a.end()) { cout<<s.c_str()<<endl; break; } } } return 0;}
阅读全文
0 0
- Compound Words
- Compound Words
- Compound Words
- Compound Words
- Compound Words
- zoj 1825 Compound Words
- uva 10391 compound words
- UVa 10391 - Compound Words
- uva 10391 - Compound Words
- uva 10391 - Compound Words
- UVa 10391 - Compound Words
- UVa 10391 - Compound Words
- Compound Words 10391
- uva 10391 - Compound Words
- 10391 - Compound Words
- UVA 10391 Compound Words
- UVA 10391 - Compound Words
- NSU-1191-Compound Words
- 56. Merge Intervals
- 乌龟棋 【多维DP】 Codevs1068
- 基于CentOS的Hadoop和Spark分布式集群搭建过程
- 1105: 判断友好数对(函数专题)
- HDU 2577 How to Type
- Compound Words
- JavaScript动态绑定(向后绑定)
- 2763: [JLOI2011]飞行路线
- 8、样式的继承、应用及优先级
- springmvc数据的格式化及数据校验
- codeforces小做
- 影响数据库性能的六大因素
- geotools中泰森多边形的生成
- plsql连接非本地数据库