c++:algorithm-find
来源:互联网 发布:网络写手收入排行 编辑:程序博客网 时间:2024/05/17 05:29
#include <cstdio>
#include <iostream>
#include <algorithm>////
#include <cstring>
#include <string>
#include <vector>
using namespace std;
int main ()
{
string a="abcdefg";
cout<<a.find("a")<<endl;//输出0
string b="fg";
cout<<a.find(b)<<endl; //输出1
////////////////////////////
string c="gg";
cout<<a.find(c)<<endl; //返回一个虚无的数
int k;
k=a.find(c);
cout<<k<<endl;
////////////////////
//所以。。。。。
cout<<"输入母串"<<endl;
string y;
cin>>y;
cout<<"输入要查找的子串"<<endl;
string x;
cin>>x;
cout<<"该子串所在的位置为---"<<endl;
int q;
q=y.find(x);
if(q==-1)cout<<"查无此串"<<endl;
else cout<<"此串位置为"<<q+1<<endl;
vector<string> m;
m.push_back("hello");
m.push_back("hello2");
m.push_back("hello3");
if (find(m.begin(), m.end(), "hello") == m.end())
cout << "no" << endl;
else
cout << "yes" << endl;
}
#include <iostream>
#include <algorithm>////
#include <cstring>
#include <string>
#include <vector>
using namespace std;
int main ()
{
string a="abcdefg";
cout<<a.find("a")<<endl;//输出0
string b="fg";
cout<<a.find(b)<<endl; //输出1
////////////////////////////
string c="gg";
cout<<a.find(c)<<endl; //返回一个虚无的数
int k;
k=a.find(c);
cout<<k<<endl;
////////////////////
//所以。。。。。
cout<<"输入母串"<<endl;
string y;
cin>>y;
cout<<"输入要查找的子串"<<endl;
string x;
cin>>x;
cout<<"该子串所在的位置为---"<<endl;
int q;
q=y.find(x);
if(q==-1)cout<<"查无此串"<<endl;
else cout<<"此串位置为"<<q+1<<endl;
vector<string> m;
m.push_back("hello");
m.push_back("hello2");
m.push_back("hello3");
if (find(m.begin(), m.end(), "hello") == m.end())
cout << "no" << endl;
else
cout << "yes" << endl;
}
0 0
- c++:algorithm-find
- STL algorithm find
- STL algorithm find() demo
- Algorithm: Find the maximum
- Algorithm.Find(查找)
- Algorithm Part I:Union-Find
- Algorithm to find square root of an algorithm
- [c++,algorithm]3_fpTree
- C++<Algorithm>学习
- C++::STL::algorithm
- c++ stl algorithm: std::find, std::find_if
- c++ stl algorithm: std::find, std::find_if
- STL algorithm算法find(16)
- Hirschberg's algorithm to find string alignment
- Disjoint-Set Data Structure (Union Find Algorithm)
- Algorithm--全排列(c#)
- (C#)排序算法 Sort Algorithm
- [c++,algorithm] 哈密尔顿回路判断
- C++ primer 5th课后题 9.19、9.20、9.26、9.27、9.28
- JSP自定义标签
- 死锁产生的原因及四个必要条件
- 赛意递归
- Android中Context的使用
- c++:algorithm-find
- 配置编译安装内核
- Codeforces Round #295 (Div. 2)-C. DNA Alignment
- cmd——窗口标题及字体颜色、背景颜色设置
- 配置tomcat环境变量
- Java实现几种常见排序方法
- 单片机的动态内存管理-一以链表为例
- 使用JDBC出现NoClassDefFoundError异常的解决方法
- JAVA从菜鸟【入门】到新手【实习】一一Python小项目(Anaconda2)2,7X