logo设计网站国外,跨境电商开发,重庆网红景点有哪些,北京网站建设需要多少钱函数
函数作用any_of区间[开始, 结束)中是否至少有一个元素都满足判断式p#xff0c;只要有一个元素满足条件就返回true#xff0c;否则返回truenone_of区间[开始, 结束)中是否所有的元素都不满足判断式p#xff0c;所有的元素都不满足条件返回true#xff0c;否则返回fal…函数
函数作用any_of区间[开始, 结束)中是否至少有一个元素都满足判断式p只要有一个元素满足条件就返回true否则返回truenone_of区间[开始, 结束)中是否所有的元素都不满足判断式p所有的元素都不满足条件返回true否则返回falseall_of区间[开始, 结束)中是否所有的元素都满足判断式p所有的元素都满足条件返回true否则返回false
示例
// 分数
std::vectorint vec_score{10 , 2, 33, 43, 52};// 是否大于100
bool is_greater_than_100 std::all_of(vec_score.begin(), vec_score.end(), [](int item) {return 100 item; });// 是否存在大于100的元素
bool is_exist_greater_than_100 std::any_of(vec_score.begin(), vec_score.end(), [](int item) {return 100 item; });// 检查所有分数是否全部不大于100
bool is_less_than_100 std::none_of(vec_score.begin(), vec_score.end(), [](int item) {return 100 item; });if (!is_greater_than_100)std::cout 不全大于100\n\n;
elsestd::cout 全大于100\n\n;if (is_exist_greater_than_100)std::cout 存在大于100的分数\n;
elsestd::cout 不存在大于100的分数\n\n;if (is_less_than_100)std::cout 所有分数都不大于100\n;
elsestd::cout 存在大于100的分数\n\n;# result
# 不全大于100
# 不存在大于100的分数
# 所有分数都不大于100