当前位置: 首页 > news >正文

做短租哪个网站好全网投放广告的渠道有哪些

做短租哪个网站好,全网投放广告的渠道有哪些,中文网站模板大全,上海专业做网站公司地址algorithm此头文件是算法库的一部分。本篇介绍不修改序列的操作函数。 不修改序列的操作 all_ofany_ofnone_of (C11)(C11)(C11) 检查谓词是否对范围中所有、任一或无元素为 true (函数模板) for_each 应用函数到范围中的元素 (函数模板) for_each_n (C17) 应用一个函数对象到序…

algorithm此头文件是算法库的一部分。本篇介绍不修改序列的操作函数。

不修改序列的操作

all_ofany_ofnone_of

(C++11)(C++11)(C++11)

检查谓词是否对范围中所有、任一或无元素为 true
(函数模板)

for_each

应用函数到范围中的元素
(函数模板)

for_each_n

(C++17)

应用一个函数对象到序列的前 n 个元素
(函数模板)

countcount_if

返回满足指定判别标准的元素数
(函数模板)

mismatch

寻找两个范围出现不同的首个位置
(函数模板)

findfind_iffind_if_not

(C++11)

寻找首个满足特定判别标准的元素
(函数模板)

find_end

在特定范围中寻找最后出现的元素序列
(函数模板)

find_first_of

搜索元素集合中的任意元素
(函数模板)

adjacent_find

查找首对相邻的相同(或满足给定谓词的)元素
(函数模板)

search

搜索一个元素范围
(函数模板)

search_n

在范围中搜索一定量的某个元素的连续副本
(函数模板)

示例代码:

#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <utility>      // std::pair
#include <vector>
#include <array>
#include <cctype>       // std::tolowervoid myfunction(int i) {  // function:std::cout << ' ' << i;
}struct myclass {           // function object type:void operator() (int i) { std::cout << ' ' << i; }
} myobject;bool IsOdd(int i) { return ((i % 2) == 1); }bool mypredicate(int i, int j) {return (i == j);
}bool myfunction8(int i, int j) {return (i == j);
}bool comp_case_insensitive9(char c1, char c2) {return (std::tolower(c1) == std::tolower(c2));
}bool myfunction10(int i, int j) {return (i == j);
}bool mypredicate11(int i, int j) {return (i == j);
}bool mypredicate12(int i, int j) {return (i == j);
}int main()
{// all_of example  检查谓词是否对范围中所有、任一或无元素为 truestd::array<int, 8> foo = { 3,5,7,11,13,17,19,23 };if (std::all_of(foo.begin(), foo.end(), [](int i) {return i % 2; }))std::cout << "All the elements are odd numbers.\n";// any_of examplestd::array<int, 7> foo2 = { 0,1,-1,3,-3,5,-5 };if (std::any_of(foo2.begin(), foo2.end(), [](int i) {return i < 0; }))std::cout << "There are negative elements in the range.\n";// none_of examplestd::array<int, 8> foo3 = { 1,2,4,8,16,32,64,128 };if (std::none_of(foo3.begin(), foo3.end(), [](int i) {return i < 0; }))std::cout << "There are no negative elements in the range.\n";// for_each example  应用函数到范围中的元素 std::vector<int> myvector;myvector.push_back(10);myvector.push_back(20);myvector.push_back(30);std::cout << "myvector contains:";for_each(myvector.begin(), myvector.end(), myfunction);std::cout << '\n';// or:std::cout << "myvector contains:";for_each(myvector.begin(), myvector.end(), myobject);std::cout << '\n';// count algorithm example 返回满足指定判别标准的元素数 // counting elements in array:int myints[] = { 10,20,30,30,20,10,10,20,10,20 };   // 8 elementsint mycount = std::count(myints, myints + 8, 10);std::cout << "10 appears " << mycount << " times.\n";// counting elements in container:std::vector<int> myvector2(myints, myints + 10);mycount = std::count(myvector2.begin(), myvector2.end(), 20);std::cout << "20 appears " << mycount << " times.\n";// count_if examplestd::vector<int> myvector3;for (int i = 1; i < 10; i++) myvector3.push_back(i); // myvector: 1 2 3 4 5 6 7 8 9int mycount3 = count_if(myvector3.begin(), myvector3.end(), IsOdd);std::cout << "myvector3 contains " << mycount3 << " odd values.\n";// mismatch algorithm example 寻找两个范围出现不同的首个位置 std::vector<int> myvector4;for (int i = 1; i < 6; i++) myvector4.push_back(i * 10); // myvector4: 10 20 30 40 50int myints4[] = { 10,20,80,320,1024 };                //   myints4: 10 20 80 320 1024std::pair<std::vector<int>::iterator, int*> mypair4;// using default comparison:mypair4 = std::mismatch(myvector4.begin(), myvector4.end(), myints4);std::cout << "First mismatching elements: " << *mypair4.first;std::cout << " and " << *mypair4.second << '\n';++mypair4.first; ++mypair4.second;// using predicate comparison:mypair4 = std::mismatch(mypair4.first, myvector4.end(), mypair4.second, mypredicate);std::cout << "Second mismatching elements: " << *mypair4.first;std::cout << " and " << *mypair4.second << '\n';// find example// using std::find with array and pointer:int myints5[] = { 10, 20, 30, 40 };int *p;p = std::find(myints5, myints5 + 4, 30);if (p != myints5 + 4)std::cout << "Element found in myints5: " << *p << '\n';elsestd::cout << "Element not found in myints5\n";// using std::find with vector and iterator:std::vector<int> myvector5(myints5, myints5 + 4);std::vector<int>::iterator it;it = find(myvector5.begin(), myvector5.end(), 30);if (it != myvector5.end())std::cout << "Element found in myvector5: " << *it << '\n';elsestd::cout << "Element not found in myvector5\n";// find_if examplestd::vector<int> myvector6;myvector6.push_back(10);myvector6.push_back(25);myvector6.push_back(40);myvector6.push_back(55);std::vector<int>::iterator it6 = std::find_if(myvector6.begin(), myvector6.end(), IsOdd);std::cout << "The first odd value is " << *it6 << '\n';// find_if_not examplestd::array<int, 5> foo7 = { 1,2,3,4,5 };std::array<int, 5>::iterator it7 = std::find_if_not(foo7.begin(), foo7.end(), [](int i) {return i % 2; });std::cout << "The first even value is " << *it7 << '\n';// find_end exampleint myints8[] = { 1,2,3,4,5,1,2,3,4,5 };std::vector<int> haystack8(myints8, myints8 + 10);int needle1[] = { 1,2,3 };// using default comparison:std::vector<int>::iterator it8;it8 = std::find_end(haystack8.begin(), haystack8.end(), needle1, needle1 + 3);if (it8 != haystack8.end())std::cout << "needle1 last found at position " << (it8 - haystack8.begin()) << '\n';int needle2[] = { 4,5,1 };// using predicate comparison:it8 = std::find_end(haystack8.begin(), haystack8.end(), needle2, needle2 + 3, myfunction8);if (it8 != haystack8.end())std::cout << "needle2 last found at position " << (it8 - haystack8.begin()) << '\n';// find_first_of exampleint mychars9[] = { 'a','b','c','A','B','C' };std::vector<char> haystack9(mychars9, mychars9 + 6);std::vector<char>::iterator it9;int needle9[] = { 'A','B','C' };// using default comparison:it9 = find_first_of(haystack9.begin(), haystack9.end(), needle9, needle9 + 3);if (it9 != haystack9.end())std::cout << "The first match is: " << *it9 << '\n';// using predicate comparison:it9 = find_first_of(haystack9.begin(), haystack9.end(),needle9, needle9 + 3, comp_case_insensitive9);if (it9 != haystack9.end())std::cout << "The first match is: " << *it9 << '\n';// adjacent_find exampleint myints10[] = { 5,20,5,30,30,20,10,10,20 };std::vector<int> myvector10(myints10, myints10 + 8);std::vector<int>::iterator it10;// using default comparison:it10 = std::adjacent_find(myvector10.begin(), myvector10.end());if (it10 != myvector10.end())std::cout << "the first pair of repeated elements are: " << *it10 << '\n';//using predicate comparison:it10 = std::adjacent_find(++it10, myvector10.end(), myfunction10);if (it10 != myvector10.end())std::cout << "the second pair of repeated elements are: " << *it10 << '\n';// search algorithm examplestd::vector<int> haystack11;// set some values:        haystack11: 10 20 30 40 50 60 70 80 90for (int i = 1; i < 10; i++) haystack11.push_back(i * 10);// using default comparison:int needle11[] = { 40,50,60,70 };std::vector<int>::iterator it11;it11 = std::search(haystack11.begin(), haystack11.end(), needle11, needle11 + 4);if (it11 != haystack11.end())std::cout << "needle11 found at position " << (it11 - haystack11.begin()) << '\n';elsestd::cout << "needle11 not found\n";// using predicate comparison:int needle21[] = { 20,30,50 };it11 = std::search(haystack11.begin(), haystack11.end(), needle21, needle21 + 3, mypredicate11);if (it11 != haystack11.end())std::cout << "needle21 found at position " << (it11 - haystack11.begin()) << '\n';elsestd::cout << "needle21 not found\n";// search_n exampleint myints12[] = { 10,20,30,30,20,10,10,20 };std::vector<int> myvector12(myints12, myints12 + 8);std::vector<int>::iterator it12;// using default comparison:it12 = std::search_n(myvector12.begin(), myvector12.end(), 2, 30);if (it12 != myvector12.end())std::cout << "two 30s found at position " << (it12 - myvector12.begin()) << '\n';elsestd::cout << "match not found\n";// using predicate comparison:it12 = std::search_n(myvector12.begin(), myvector12.end(), 2, 10, mypredicate12);if (it12 != myvector12.end())std::cout << "two 10s found at position " << int(it12 - myvector12.begin()) << '\n';elsestd::cout << "match not found\n";std::cout << "hello world\n";return 0;
}

运行结果:

参考:

https://cplusplus.com/reference/algorithm/

https://zh.cppreference.com/w/cpp/header/algorithm

http://www.qdjiajiao.com/news/6555.html

相关文章:

  • 深圳做网站公司有哪些现在最火的推广平台
  • php网站开发面向对象教程今天新闻联播
  • qq发网站链接怎么做营销推广的主要方法
  • 打开网上免费网站吗南宁百度seo价格
  • 集团公司网站 案例市场调研报告怎么写范文
  • 手机网站 怎么开发网站服务器
  • 杭州做网站怎么收费小红书关键词排名
  • WordPress导入用户数据关键词优化快排
  • 织梦仿站 用标签生成器 替换了css 但网站还是错位常州seo第一人
  • 快速网站排名提升工具怎样建立个人网站
  • 武汉网站建设运营沪深300指数基金排名
  • 微信网站的链接标志图片如何做搜索引擎seo是什么
  • 网站建设的常用技术微博推广费用一般多少
  • 2018年怎样做淘宝客网站西安seo培训学校
  • 织梦可以做B2B信息发布网站吗广州网站设计建设
  • 郑州建站系统在线咨询自媒体平台注册入口官网
  • 女性pose拍照沈阳专业seo关键词优化
  • 深圳网站建设公司设计公司山东公司网站推广优化
  • 衙门口网站建设电脑培训班电脑培训学校
  • 衣服网购平台哪个最好win7怎么优化最流畅
  • 深圳网站建设服务哪便宜东台网络推广
  • 长沙门户网站百度竞价效果怎么样
  • 更换wordpress后台登陆地址seo基础理论
  • 国外优秀设计网站有哪些关键词快速排名不限行业
  • 网站如何实现多语言网站网址大全
  • 做网站建站网络营销推广seo
  • 网站模版怎么上传到空间网站搜索优化公司
  • 微信自己怎么弄小程序抖音排名优化
  • 做公众号的必备参考网站今日足球比赛分析推荐
  • 上海网站建设报价单子现说深圳市推广网站的公司