UVA_10391: Compound Words
来源:互联网 发布:淘宝哪家店是阿迪正品 编辑:程序博客网 时间:2024/06/04 19:07
分析:读取所有字符串到字符数组中并存在map中建立映射,之后进入主循环,遍历每个字符串,按长度截取成两个字符串,分别在map中查找,如果找到了说明可以拆,进行下一个,不能继续找。
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <map>using namespace std;char words[120010][30];map<string,int> wmap;int main(){int n=0;while(~scanf("%s",words[n])){wmap[words[n]]=1;n++;}for(int i=0; i<n; i++){int len = strlen(words[i]);for(int j=0; j<len; j++){char t1[30] = {0};char t2[30] = {0};strncpy(t1,words[i],j);strncpy(t2,words[i]+j,len-j);if(wmap[t1] && wmap[t2]){printf("%s\n",words[i]);break;}}} return 0;}
0 0
- UVA_10391: Compound Words
- 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
- Linux块设备驱动之内存模拟块设备
- mybatis解决字段名与实体类属性名不相同的冲突
- 一个Go推送服务器集群:gopush-cluster
- 获取app的主窗口,返回主视图界面
- 常规load方式
- UVA_10391: Compound Words
- 被锁 和解锁
- 通过ICursor对Table进行操作(添加、修改、删除)
- Learn more study less 读后感
- 大数据之数据挖掘理论笔记 聚类问题之K-means
- SQL*LOADER
- 关于ActivityA中的FragmentA 启动 ActivityB,FragmentA的startActivityForResult回调的问题
- LeetCode 071 Simplify Path
- hello.cpp:1:24: fatal error: QApplication: No such file or directory