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。
返回值
元素是元素的valarray _Left 其余部分由 _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;
}
要求
标头: <valarray>
命名空间: std