直接代码:
#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;
}
分享到:
相关推荐
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 ...
ForwardIterator1 find_first_of (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2) { if (first2 == last2) return first1; ForwardIterator1 next = ...
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 ...
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 ...
一、非修改性序列操作(12个) 循环 对序列中的每个元素...在序列中找出第一次出现指定值集中之值的位置 find_first_of() 在序列中找出相邻的一对值 adjacent_find() 计数 在序列中统计某个值出现的次数 count()
(1)简单查找算法 (1) find(beg, end, val) //返回迭代器,若找到指向指定元素迭代器 (6) find_first_of(beg1, e
/** compare the left child and right child to find the min one */ if(((huffman_node_array[cur])->data_8bit_count)>((huffman_node_array[cur 1])->data_8bit_count)){ cur =1; ...
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 ...
find_first_of (cppstring) find_last_not_of (cppstring) find_last_of (cppstring) flags (cppio) flip (cppbitset) floor (stdmath) flush (cppio) fmod (stdmath) fopen (stdio) fprintf ...
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...
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 子序列...
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 子序列...
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 子序列...
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.
%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)...
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 ); // ...
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...
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 ...
by the set of precesses consuming more than <size_mb> MB of PGA memory (-mem option) - pgasnap [] Snapshot the pga advice stats - pgaadv [-s []] [-o graphfile] [-m min_size]: generate a graph ...
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. ...