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 newborn

题意:

给出几个串,输出能有里面的串组成的串

思路:

将每个串存在集合里面,然后将每个串截成不同形式,在集合里寻找是否有这个串

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long LL;
int main()
{
string str;
set<string> Set;
while(cin>>str)
{
Set.insert(str);
}
set<string>::iterator it;
for(it=Set.begin();it!=Set.end();it++)
{
string str1=*it;
int l=str1.size();
for(int i=;i<l;i++)
{
string one=str1.substr(,i+);
string two=str1.substr(i+,l-i);
if(Set.find(one)!=Set.end()&&Set.find(two)!=Set.end())
{
cout<<str1<<endl;
break;
}
}
}
return ;
}

代码:

最新文章

  1. CSS3-canvas绘制线性渐变
  2. IOS开发中单例模式使用详解
  3. 吉哥系列故事--完美队形 - HDU 4513 (Manacher)
  4. AS 进行单元测试
  5. Hadoop配置文件-hdfs-site.xml
  6. hdu2410(水)
  7. Json对象与Json字符串的转化、JSON字符串与Java对象的转换
  8. sha256 js 前端加密
  9. Ceres Solver 入门稍微多一点
  10. CLion之C++框架篇-安装工具,基础框架的搭建(一)
  11. zookeeper 实现分布式锁安全用法
  12. zabbix学习小结
  13. UML和模式应用3:迭代和进化式分析和设计案例研究
  14. [转载]Oracle左连接、右连接、全外连接以及(+)号用法
  15. swagger实战踩坑1
  16. Win10系列:JavaScript 项目模板和项模板
  17. KnockoutJs学习笔记(十二)
  18. 在Ubuntu的系统中怎样将应用程序加入到開始菜单中
  19. 微信公众号获取粉丝openid系统
  20. 2018-2019 20165226 Exp6 信息搜集与漏洞扫描

热门文章

  1. 用js(JavaScript-jQuery)解析XML文件 无法成功 获得XML对象,字符串一些心得
  2. 8086实时时钟实验(一)——《x86汇编语言:从实模式到保护模式》05
  3. Linux下Makefile的automake生成全攻略--转
  4. C# 类型、对象、线程栈和托管堆在运行时的关系
  5. django管理界面使用与bootstrap模板使用
  6. .NET Core 部署到CentOS&ndash;1.创建项目,简单部署
  7. struts2 :Unable to load configuration. ……struts-default.xml:46:178异常解决
  8. 数组和矩阵(1)——Find the Duplicate Number
  9. JS自定义手机端H5键盘
  10. 日期函数new Date()浏览器兼容性问题