题目描述:

题目思路:

用map保存所有单词赋键值1,拆分单词,用map检查是否都为1,即为复合词

 #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string,int> dict ;
string str[] ;
int main(int argc, char *argv[])
{
int count = ;
while(cin >> str[count]){
dict[str[count]] = ;
count ++ ;
}
for(int i = ;i < count ;i++){
for(int j = ;j < str[i].length() ;j++){
string word1,word2 ;
word1 = str[i].substr(,j) ;
word2 = str[i].substr(j) ;
if(dict[word1] && dict[word2]) {
cout << str[i] << '\n';
break;
}
}
}
return ;
}

复合词 (Compund Word,UVa 10391)的更多相关文章

  1. 复合词(Compound Words, UVa 10391)(stl set)

    You are to find all the two-word compound words in a dictionary. A two-word compound word is a word i ...

  2. UVA 10391 - Compound Words 字符串hash

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  3. UVA 10391 stl

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. UVa 10391 (水题 STL) Compound Words

    今天下午略感无聊啊,切点水题打发打发时间,=_=|| 把所有字符串插入到一个set中去,然后对于每个字符串S,枚举所有可能的拆分组合S = A + B,看看A和B是否都在set中,是的话说明S就是一个 ...

  5. uva 10391 Compound Words <set>

    Compound Words You are to find all the two-word compound words in a dictionary. A two-word compound ...

  6. UVA 10391 Compound Words

    Problem E: Compound Words You are to find all the two-word compound words in a dictionary. A two-wor ...

  7. Compound Words UVA - 10391

      You are to find all the two-word compound words in a dictionary. A two-word compound word is a wor ...

  8. uva 10391

    这个题,单纯做出来有很多种方法,但是时间限制3000ms,因此被TL了不知道多少次,关键还是找对最优解决方法,代码附上: #include<bits/stdc++.h> using nam ...

  9. UVa第五章STL应用 习题((解题报告))具体!

    例题5--9 数据库 Database UVa 1592 #include<iostream> #include<stdio.h> #include<string.h&g ...

随机推荐

  1. Vue教程:过滤器filters(五)

    Vue.js 允许你自定义过滤器,可被用于一些常见的文本格式化.过滤器可以用在两个地方:双花括号插值和 v-bind 表达式 (后者从 2.1.0+ 开始支持).过滤器应该被添加在 JavaScrip ...

  2. 课时46.label标签(掌握)

    我们点击QQ注册页面,发现了一个问题,当我们点击密码两个字的时候,输入框聚焦了,而点击确认密码的时候,输入框也聚焦了,而我们上节课做的页面,这么点击,并不聚焦 1.默认情况下文字和输入框是没有关联关系 ...

  3. 使用第三方库iOS-ECharts做柱状图的心得

    最近的项目里面用到了饼图和条形统计图,饼图用的是PNChart来做的,这个库感觉用起来也简单,但是做条形统计图的时候就特别蛋疼(不知道是不是我姿势没对),反正就是各种问题,然后就想到换一种框架,最后选 ...

  4. AFNetworking 打印错误信息(二进制信息)

    AFNetworking 打印错误信息(二进制信息) NSError *underError = error.userInfo[@"NSUnderlyingError"]; NSD ...

  5. 如何编写及运行JS

    JS也是一种脚本语言,他可以有两种方式在HTML页面进行引入,一种是外联,一种是内部.       外联JS的写法为: <script src="相对路径"></ ...

  6. 爬虫——Scrapy框架案例二:阳光问政平台

    阳光热线问政平台 URL地址:http://wz.sun0769.com/index.php/question/questionType?type=4&page= 爬取字段:帖子的编号.投诉类 ...

  7. 安装psutil时提示缺少python.h头文件(作记录)

    通过pip或者源码安装psutil,都会提示缺少python.h头文件,错误提示如下: ... psutil/_psutil_common.c:9:20: fatal error: Python.h: ...

  8. day 24 内置模块re

    1.正则表达式,匹配字符串 正则表达式是对字符串操作的一种逻辑公式.我们一般使用正则表达式对字符串镜子那个匹配和过滤,使用正则的优缺点: 优点: 灵活,功能性强,逻辑性强 缺点: 上手难.一旦上手,会 ...

  9. checked和unchecked转换

    static unsafe void Main(string[] args) { unchecked //checked 运行时候引发异常 { int n = int.MaxValue; n++; C ...

  10. 20190120-自定义实现split方法

    1. 实现字符串的split方法Python split() 通过指定分隔符对字符串进行切片,如果参数 num 有指定值,则分隔 num+1 个子字符串 思路同自定义实现replace方法类型: 1. ...