题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=91209#problem/C

题意:   有一堆按照字典序排好的字符串,问你有多少字符串是由其它两个字符串组成。

法一:STL  set

#include <iostream>
#include <set>
#include <cstdio>
#include <string>
using namespace std; set <string> mys; int main(){
string st;
set <string>::iterator it;
while(cin>>st) mys.insert(st); //插入mys
for(it=mys.begin();it!=mys.end();it++){
st=*it;
for(int i=;i<st.length()-;i++){
string sub1=st.substr(,i+);
string sub2=st.substr(i+,st.length()-(i+)); //http://www.w3school.com.cn/php/func_string_substr.asp
if( mys.find(sub1)!=mys.end() && mys.find(sub2 )!=mys.end() ){
printf("%s\n",st.c_str());
break;
}
}
}
return ;
}

法二:

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char ss[][];
int bj(char *s,int n)
{
int l=,r=n-,mid,x;
while (l<=r)
{
mid=(l+r)/;
x=strcmp(s,ss[mid]);
if(x==)
return ;
if(x<)
r=mid-;
else l=mid+;
}
return ;
}
int main()
{
char s1[],*s2;
int n,j,i,len,k;
i=;
while(~scanf("%s", ss[i])) i++;
n=i;
for(i=;i<n;i++)
{
len=strlen(ss[i]);
for( j=,k=;j<len-;j++)
{
s1[k++]=ss[i][j];
s1[k]='\0';
s2=ss[i]+j+;
if(bj(s1,n)&&bj(s2,n))
{
printf("%s\n",ss[i]);
break;
}
}
}
return ;
}

Compound Words的更多相关文章

  1. 【英语魔法俱乐部——读书笔记】 2 中级句型-复句&合句(Complex Sentences、Compound Sentences)

    [英语魔法俱乐部——读书笔记] 2 中级句型-复句&合句(Complex Sentences.Compound Sentences):(2.1)名词从句.(2.2)副词从句.(2.3)关系从句 ...

  2. eclipse提示:This tag and its children can be replaced by one <TextView/> and a compound drawable

    今天在学习android开发的时候,写了这样的一段代码: <?xml version="1.0" encoding="utf-8"?> <Li ...

  3. Compound Interest Calculator4.0

    Compound Interest Calculator4.0 1.团队协作准备:每个同学在github上完成FORK,COMMENT(学号后三位+姓名),PR,MERGE的过程. 2.你的RP由你的 ...

  4. Compound Interest Calculator3.0

    Compound Interest Calculator3.0 1.利率这么低,复利计算收益都这么厉害了,如果拿100万元去买年报酬率10%的股票,若一切顺利,过多长时间,100万元就变成200万元呢 ...

  5. Compound Interest Calculator2.0

    Compound Interest Calculator2.0 1.如果按照单利计算,本息又是多少呢? 2.假如30年之后要筹措到300万元的养老金,平均的年回报率是3%,那么,现在必须投入的本金是多 ...

  6. Compound Interest Calculator1.0

    Compound Interest Calculator1.0 客户说:帮我开发一个复利计算软件. 计算:本金为100万,利率或者投资回报率为3%,投资年限为30年,那么,30年后所获得的利息收入:按 ...

  7. EnCase v7 search hits in compound files?

    I used to conduct raw search in EnCase v6, and I'd like to see if EnCase v7 raw search could hit key ...

  8. How to search compound files

    Last week my friend told me that she made a terrible mistake. She conducted raw serch and found no s ...

  9. 设计模式学习--复合模式(Compound Pattern)

    设计模式学习--复合模式(Compound Pattern) 概述 ——————————————————————————————————————————————————— 2013年8月4日<H ...

  10. uva 10391 Compound Words <set>

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

随机推荐

  1. hdu 4763 kmp ***

    找AEAEA形式的字符串最长的A长度,E可以为空 只可意会,不可言传,懂kmp即可 #include <stdio.h> #include <string.h> #includ ...

  2. ASP.NET 5探险(5):利用AzureAD实现单点登录

    题记:在ASP.NET 5中虽然继续可以沿用ASP.NET Identity来做验证授权,不过也可以很容易集成支持标准协议的第三方服务,比如Azure Active Directory. 其实,在AS ...

  3. 把浏览器的私有模式添加到VS中

    题记:在用VS进行Web开发的时候,常常希望VS的调试不会对浏览器造成固定的影响,那么使用浏览器的私有模式来启动就很有必要. 前几天SCOTT HANSELMAN分享了一个开发Web应用程序的小技巧, ...

  4. RTP、RTCP及媒体流同步

    转自:http://blog.163.com/liu_nongfu/blog/static/19079414220139169225333/ 一.流媒体简介 流媒体是指在internet中使用流媒体技 ...

  5. winows下使用ssh服务远程登录vbox中的虚拟机

    1.到http://www.putty.org/下载并安装SSH客户端 2.查看是否安装ssh服务 在ubuntu终端命令界面键入: #ssh localhost 如果出现下面提示则表示还没有安装: ...

  6. ARM寄存器学习,王明学learn

    ARM寄存器学习 ARM微处理器共有37个32位寄存器,其中31个为通用寄存器,6个为状态寄存器.但是这些寄存器不能被同时访问,具体哪些寄存器是可以访问的,取决ARM处理器的工作状态及具体的运行模式. ...

  7. UI背景构建

    个中原因不是很明白 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android=& ...

  8. 标准MDL方法修改Page、NonPage内存的属性

    typedef struct _REPROTECT_CONTEXT { PMDL   Mdl; PUCHAR LockedVa; } REPROTECT_CONTEXT, * PREPROTECT_C ...

  9. bzoj专题训练

    //http://blog.csdn.net/PoPoQQQ/article/category/2542243

  10. 【java IO】使用Java输入输出流 读取txt文件内数据,进行拼接后写入到另一个文件中

    package com.sxd.test.util; import java.io.BufferedReader; import java.io.BufferedWriter; import java ...