`
java-mans
  • 浏览: 11415642 次
文章分类
社区版块
存档分类
最新评论

find_end,find_first_of

 
阅读更多

直接代码:

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int a[]={1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10};
	vector<int>v(a,a+20);
	vector<int>vv(a+3,a+8);
	vector<int>::iterator end=v.end();
	vector<int>::iterator it;
	it=find_end(v.begin(),v.end(),vv.begin(),vv.end());
	while(it!=end){
		cout<<"found "<<distance(v.begin(),it)<<endl;
		end=it;
		it=find_end(v.begin(),end,vv.begin(),vv.end());
	}
	system("pause");
	return 0;
}
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int a[]={1,2,3,4,5,6,7,8,9,10};
	vector<int>v(a,a+10);
	vector<int>vv(a+3,a+8);

	vector<int>::iterator it=find_first_of(v.begin(),v.end(),vv.begin(),vv.end());
	//cout<<distance(v.begin(),it)<<endl;
	//cout<<*it<<endl;
	while(it!=v.end()){
		cout<<"found"<<distance(v.begin(),it)<<endl;
		++it;
		it=find_first_of(it,v.end(),vv.begin(),vv.end());
	}
	system("pause");
	return 0;
}
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
bool chenger(int a,int b){
	return a*2==b;
}
using namespace std;
int main(){
	int a[]={1,2,3,4,5,6,7,8,9,10};
	vector<int>v(a,a+10);
	vector<int>vv(a+3,a+8);
	for(vector<int>::iterator ite=vv.begin();ite!=vv.end();++ite){
		cout<<*ite<<" ";
	}
	cout<<endl;
	vector<int>::iterator it=find_first_of(v.begin(),v.end(),vv.begin(),vv.end(),chenger);
	cout<<*it<<endl;
	system("pause");
	return 0;
}
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;
int main(){
	int a[]={1,2,3,4,5,6,7,8,9,10};
	vector<int>v(a,a+10);
	vector<int>vv(a+3,a+8);
	
	vector<int>::iterator first;
	vector<int>::reverse_iterator last;
	first=find_first_of(v.begin(),v.end(),vv.begin(),vv.end());
	last=find_first_of(v.rbegin(),v.rend(),vv.begin(),vv.end());
	cout<<"the first location: "<<distance(v.begin(),first)<<endl;
	cout<<"the last locatioin: "<<distance(v.begin(),last.base())<<endl;
	system("pause");
	return 0;
}


分享到:
评论

相关推荐

    e_atan2.rar_atan2_return

    find_end, with and without an explicitly supplied comparison function. Search [first2, last2) as a subsequence in [first1, last1), and return the last possible match. Note that find_end for ...

    SGI-STL 源码以及 word 注解版

    ForwardIterator1 find_first_of (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2) { if (first2 == last2) return first1; ForwardIterator1 next = ...

    《C++String深入详解2.0版》PDF

    1.2.17 find_first_of 8 1.2.18 find_last_not_of 8 1.2.19 find_last_of 8 1.2.20 get_allocator 8 1.2.21 insert 8 1.2.22 length 8 1.2.23 max_size 8 1.2.24 push_back 8 1.2.25 rbegin 8 1.2.26 rend 8 1.2.27 ...

    《深入学习c++string》2.1版

    1.2.17 find_first_of 8 1.2.18 find_last_not_of 9 1.2.19 find_last_of 9 1.2.20 get_allocator 9 1.2.21 insert 9 1.2.22 length 9 1.2.23 max_size 9 1.2.24 push_back 9 1.2.25 rbegin 9 1.2.26 rend 9 1.2.27 ...

    浅谈头文件algorithm中的常用函数

    一、非修改性序列操作(12个) 循环 对序列中的每个元素...在序列中找出第一次出现指定值集中之值的位置 find_first_of() 在序列中找出相邻的一对值 adjacent_find() 计数 在序列中统计某个值出现的次数 count()

    STL使用1

    (1)简单查找算法 (1) find(beg, end, val) //返回迭代器,若找到指向指定元素迭代器 (6) find_first_of(beg1, e

    无损压缩、解压缩小程序Jcompress.zip

     /** compare the left child and right child to find the min one */   if(((huffman_node_array[cur])-&gt;data_8bit_count)&gt;((huffman_node_array[cur 1])-&gt;data_8bit_count)){   cur =1;  ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    index (counted from the first index instead of the first list item). - FIX: In THistory.DeleteActions added validation of FActionIndex (FActionIndex could appear beyond the list boundaries). Thanks ...

    c/c++函数库说明(api)html版

    find_first_of (cppstring) find_last_not_of (cppstring) find_last_of (cppstring) flags (cppio) flip (cppbitset) floor (stdmath) flush (cppio) fmod (stdmath) fopen &#40;stdio&#41; fprintf ...

    Fundamental of Electric Circuits-4e.pdf

    opment of space exploration continues to find itself impacting terres- trial technology in many important ways. For some of you, this will be an important career path. FEATURES New to This Edition A...

    C++ STL 开发技术导引(第6章)

    21.5 范围查找容器元素find_first_of 289 21.6 统计等于某值的容器元素个数count 290 21.7 条件统计容器元素个数count_if 291 21.8 元素不匹配查找mismatch 293 21.9 元素相等判断equal 295 21.10 子序列...

    C++ STL开发技术导引(第5章)

    21.5 范围查找容器元素find_first_of 289 21.6 统计等于某值的容器元素个数count 290 21.7 条件统计容器元素个数count_if 291 21.8 元素不匹配查找mismatch 293 21.9 元素相等判断equal 295 21.10 子序列...

    C++ STL开发技术导引(第3章)

    21.5 范围查找容器元素find_first_of 289 21.6 统计等于某值的容器元素个数count 290 21.7 条件统计容器元素个数count_if 291 21.8 元素不匹配查找mismatch 293 21.9 元素相等判断equal 295 21.10 子序列...

    ARM® Cortex® M4 Cookbook

    This book is aimed at those with an interest in designing and programming ... By the end of the book, you will be able to successfully create robust and scalable ARM® Cortex® based applications.

    基于lf蚁群聚类算法

    %local updating for the first itertion tao(c_index(1),g(NC,k))=(1-rou)*tao(c_index(1),g(NC,k)))+rou*initao(c_index(1),g(NC,k)); solution(k)=solution_medium(k,1); for s=2:(n-1) c_index(s)=0; r_index(s)...

    Customizable Contraction Hierarchies开源代码

    auto tail = invert_inverse_vector(graph.first_out); // Build the shortest path index auto ch = ContractionHierarchy::build( graph.node_count(), tail, graph.head, graph.travel_time ); // ...

    -C++参考大全(第四版) (2010 年度畅销榜

    34.12 find_first_of 34.13 find_if 34.14 for_each 34.15 generate和generate_n 34.16 includes 34.17 inplace_merge 34.18 iter_swap 34.19 lexicographical_compare 34.20 lower_bound 34.21 make_heap 34.22 max...

    STL源码剖析.pdg

    find_first_of 348 for_each 348 generate 349 generate_n 349 includes (应用于有序区间) 349 max_element 352 merge (应用于有序区间) 352 min_element 354 partition 354 remove 357 remove_copy ...

    ora分析脚本

    by the set of precesses consuming more than &lt;size_mb&gt; MB of PGA memory (-mem option) - pgasnap [] Snapshot the pga advice stats - pgaadv [-s []] [-o graphfile] [-m min_size]: generate a graph ...

    一个win32下的ARM开源编译器

    fasmarm follows this principle: Find a way to encode it, the smaller the better What this means is that even though you may write a particular opcocde, fasmarm may assemble another as a replacement. ...

Global site tag (gtag.js) - Google Analytics