判断数组里面的元素是否都为某个数——C++ 算法库(std::all_of)

函数功能:检测表达式是否对范围[first, last)中所有元素都返回true,如果都满足,则返回true。

该函数对整个数组元素进行操作,可以节省运行循环来逐一检查每个元素的时间。 它检查每个元素上的给定属性,并在范围内的每个元素满足指定属性时返回 true,否则返回 false。 语法:

template 
bool all_of (InputIterator first, InputIterator last, UnaryPredicate pred);
    first : Input iterators to the initial positions in a sequence.
    last : Input iterators to the final positions in a sequence.
    pred : An unary predicate function that accepts an element and returns a 			bool.
1、判断数组里面的元素是否全为0:
#include 
#

你可能感兴趣的:(C++《i+1》,算法,c++,开发语言)