valarray::operator%=

获取部件数组的元素其余元素由指定的valarray或由元素类型的值。

valarray<Type>& operator%=(
   const valarray<Type>& _Right
);
valarray<Type>& operator%=(
   const Type& _Right
);

参数

  • _Right
    元素类型的valarray或值与是将valarray的操作数,元素,valarray的操作数。

返回值

元素是从该操作数元素部门的其余部分valarray由 _Right.的valarray

示例

// valarray_class_op_rem.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   valarray<int> vaL ( 6 ), vaR ( 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 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;

   vaL %= vaR;
   cout << "The remainders from the element-by-element "
        << "division is the\n valarray: ( ";
      for ( i = 0 ; i < 6 ; i++ )
         cout << vaL [ i ] << " ";
   cout << ")." << endl;
}
  
  
  

要求

标头: <valarray>

命名空间: std

请参见

参考

valarray Class