operator%
通过一个指定获取划分为两同样的大小 valarrays 的对应元素的或 valarray 划分或拆分一个指定的 valarray。
template<class Type>
valarray<Type> operator%(
const valarray<Type>& _Left,
const valarray<Type>& _Right
);
template<class Type>
valarray<Type> operator%(
const valarray<Type>& _Left,
const Type& _Right
);
template<class Type>
valarray<Type> operator%(
const Type& _Left,
const valarray<Type>& _Right
);
参数
_Left
值或 valarray 该用作另一值或将 valarray 划分的被除数。_Right
值或 valarray 该用作除数,该除以另一值或 valarray。
返回值
元素是 _Left 元素的 valarray 余下部分通过划分 _Right.
示例
// valarray_op_rem.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
valarray<int> vaL ( 6 ), vaR ( 6 );
valarray<int> vaREM ( 6 );
for ( i = 0 ; i < 6 ; i += 2 )
vaL [ i ] = 53;
for ( i = 1 ; i < 6 ; i += 2 )
vaL [ i ] = -67;
for ( i = 0 ; i < 6 ; i++ )
vaR [ i ] = 3*i+1;
cout << "The initial Left valarray is: ( ";
for ( i = 0 ; i < 6 ; i++ )
cout << vaL [ i ] << " ";
cout << ")." << endl;
cout << "The initial Right valarray is: ( ";
for ( i = 0 ; i < 6 ; i++ )
cout << vaR [ i ] << " ";
cout << ")." << endl;
vaREM = ( vaL % vaR );
cout << "The remainders from the element-by-element "
<< "division is the\n valarray: ( ";
for ( i = 0 ; i < 6 ; i++ )
cout << vaREM [ i ] << " ";
cout << ")." << endl;
}
要求
Header: <valarray>
命名空间: std