C++ STL子序列匹配
来源:互联网 发布:上海谷歌优化公司 编辑:程序博客网 时间:2024/06/05 06:43
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <list>
#include <set>
#include <cstdlib>
using namespace std;
template <class Integer>
struct congruent
{
congruent(Integer mod)
{
N=mod;
}
bool operator()(Integer a,Integer b)const
{
return (a-b)%N==0;
}
Integer N;
};
int main()
{
const char s1[]="Hello,world!";
const char s2[]="world";
const int N1=strlen(s1);
const int N2=strlen(s2);
const char* p=search(s1,s1+N1,s2,s2+N2);
if(p!=s1+N1)
cout<<p-s1<<endl;
else
cout<<"error"<<endl;
/**************带条件的search*****************************/
int A[10]={23,46,81,2,43,19,14,98,72,51};
int digits[3]={1,2,3};
int* seq=search(A,A+10,digits,digits+3,congruent<int>(10));//???执行过程
if(seq!=A+10)
cout<<seq-A<<endl;
else
cout<<"error"<<endl;
/**************find_end()查找最后匹配的字符串*****************************/
char* s="executable.exe";
char* suffix="exe";
const int N=strlen(s);
const int N_suf=strlen(suffix);
char* location=find_end(s,s+N,suffix,suffix+N_suf);
if(location!=s+N)
cout<<location-s<<" "<<location<<endl;
return 0;
}
- C++ STL子序列匹配
- 最长公共子序列STL
- 所有子序列和STL
- 模式匹配与子序列
- STL求最长上升子序列
- C++STL之序列容器
- c++-STL:删除子串
- C 最大子序列问题
- C++STL序列式容器的学习
- 最长公共子串、最长公共子序列、最长回文子串、模式匹配、最大子序列--字符串问题整理
- 最长公共子串、最长公共子序列、最长回文子串、模式匹配、最大子序列--字符串问题整理
- LIS 模板 (最长上升/下降子序列) STL实现
- hdoj1160 FatMouse's Speed ( STL + 最长下降子序列 /DP)
- NYOJ 17 单调递增最长子序列 (二分 STL,lower_bound)
- 最长连续相异子序列 STL.MAP + DP
- POJ3903(dp最长上升子序列STL)
- 基因匹配Match(最长公共子序列) NlongN
- 最长匹配子序列 和 删除次数最小形成回文
- URAL 1012. K-based Numbers. Version 2
- #71 C
- 扑克洗牌(乱数排列)
- 深度优先遍历
- Ubuntu安裝Apache + MySQL + PHP
- C++ STL子序列匹配
- Chrome 11的安装问题
- 小山羊与吹箫的狼
- 青蛙庸医
- ghost做系统及工具软件
- 错误提示
- Compact Framework 上的 Open Source UI Library
- 正则表达式的构造摘要
- 蚂蚁与鸽子