Compound Words
来源:互联网 发布:软件poc产品 编辑:程序博客网 时间:2024/05/18 00:47
题意:
给出几个串,输出能有里面的串组成的串
思路:
将每个串存在集合里面,然后将每个串截成不同形式,在集合里寻找是否有这个串
代码:
#include<iostream>#include<cstdio>#include<string>#include<set>#include<algorithm>using namespace std;int main() {string s;set<string> res;while(cin>>s) {res.insert(s);}for(set<string>::iterator it=res.begin(); it!=res.end(); it++) {string a = *it;int n = a.size();for(int i=0; i<n; i++) {string one = a.substr(0, i+1);string two = a.substr(i+1, n-i);if(res.find(one) != res.end() && res.find(two) != res.end()) {cout<<a<<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
- bzoj3680 吊打XXX 爬山算法
- 广播接收者(2)
- const与sizeof
- 杭电oj 2002 计算球的体积
- iOS面试-WebView一些知识
- Compound Words
- 自考C++程序设计试题2010年10月
- 安卓带EditText的区域整体压缩
- 【BZOJ1997】[Hnoi2010]Planar【平面图判定】【2-SAT】
- linux下Apache配置
- SpringMVC框架前端传递List限制大小256问题
- 更改包名问题
- Python爬虫系列:1
- C++接口实现总结