std::cout<<"There are "<<std::count(v.begin(),v.end(),10)<<" tens"<<'\n';
1234
autov2=v;if(std::equal(v.begin(),v.end(),v2.begin())){std::cout<<"v and v2 are the same"<<'\n';}
1234567
autoposition=std::find(v.begin(),v.end(),10);if(position!=v.end()){std::cout<<"A ten was found in position "<<position-v.begin()<<'\n';}else{std::cout<<"A ten was not found in any position"<<'\n';}
1 2 3 4 5 6 7 8 910
std::vector<int>set={16,15,14};autoposition2=std::find_first_of(v.begin(),v.end(),set.begin(),set.end());if(position2!=v.end()){std::cout<<"An element from the set was found in position "<<position2-v.begin()<<'\n';}else{std::cout<<"An element from the set was not found in any position"<<'\n';}
12345
v2[v2.size()/3]++;autompair=std::mismatch(v.begin(),v.end(),v2.begin());std::cout<<"Elements "<<*mpair.first<<" and "<<*mpair.second<<" mismatched at position "<<mpair.first-v.begin()<<'\n';
1234567
autoi1=std::adjacent_find(v.begin(),v.end());if(i1==v.end()){std::cout<<"No matching adjacent elements"<<'\n';}else{std::cout<<"The first adjacent pair of equal elements at: "<<std::distance(v.begin(),i1)<<'\n';}
123456789
std::vector<int>target={v[30],v[31],v[32]};autoresult=std::search(v.begin(),v.end(),target.begin(),target.end());if(result==v.end()){std::cout<<"Subsequence not found"<<'\n';}else{std::cout<<"First subsequence is at: "<<std::distance(v.begin(),result)<<'\n';}
12345678
std::vector<int>v3={v[30],v[31],v[32]};autoresult2=std::find_end(v.begin(),v.end(),v3.begin(),v3.end());if(result2==v.end()){std::cout<<"Subsequence not found"<<'\n';}else{std::cout<<"Last subsequence is at: "<<std::distance(v.begin(),result2)<<'\n';}
v2=v;std::nth_element(v2.begin(),v2.begin()+v2.size()/2,v2.end());std::cout<<"The median is "<<v[v.size()/2]<<'\n';std::nth_element(v2.begin(),v2.begin()+1,v2.end());std::cout<<"The second smallest element is "<<v2[1]<<'\n';
123456
std::sort(v.begin(),v.end());// prepareif(std::binary_search(v.begin(),v.end(),15)){std::cout<<"Element 15 found"<<'\n';}else{std::cout<<"Element 15 not found"<<'\n';}
1234567
autolower=std::lower_bound(v.begin(),v.end(),15);if(lower!=v.end()){std::cout<<"First 15 at position "<<lower-v.begin()<<'\n';}else{std::cout<<"15 not found"<<'\n';}
1234567
autoupper=std::upper_bound(v.begin(),v.end(),15);if(upper!=v.end()){std::cout<<"Last 15 at position "<<upper-v.begin()<<'\n';}else{std::cout<<"Last 15 not found"<<'\n';}
12345
autorange=std::equal_range(v.begin(),v.end(),15);if(range.first!=v.end()){std::cout<<"15 from positions "<<range.first-v.begin()<<" to "<<range.second-v.begin()<<'\n';}
12345
std::make_heap(v.begin(),v.end());std::for_each(v.begin(),v.end(),[](constintc){std::cout<<c<<" ";});std::cout<<'\n';std::cout<<"The largest element is "<<v.front()<<'\n';
automax_i=std::max_element(v.begin(),v.end());std::cout<<"Max element at: "<<std::distance(v.begin(),max_i)<<'\n';
123
automin_i=std::min_element(v.begin(),v.end());std::cout<<"Min element at: "<<std::distance(v.begin(),min_i)<<'\n';
123
autoresult=std::minmax_element(v.begin(),v.end());std::cout<<"min element at: "<<(result.first-v.begin())<<'\n';std::cout<<"max element at: "<<(result.second-v.begin())<<'\n';
123456
std::vector<int>v1{1,2,3,4,5};std::vector<int>v2{3,5,4,1,2};std::cout<<"3,5,4,1,2 is a permutation of 1,2,3,4,5? "<<std::boolalpha<<std::is_permutation(v1.begin(),v1.end(),v2.begin())<<'\n';
std::vector<int>a{0,1,2,3,4};std::vector<int>b{5,4,2,3,1};intr1=std::inner_product(a.begin(),a.end(),b.begin(),0);std::cout<<"Inner product of a and b: "<<r1<<'\n';