operator/ (<valarray>)

获取在两个具有相同大小的valarrays的对应元素的组件或控件之间的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_equo.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>

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

   valarray<double> vaL ( 6 ), vaR ( 6 );
   valarray<double> vaNE ( 6 );
   for ( i = 0 ; i < 6 ; i += 2 )
      vaL [ i ] =  100;
   for ( i = 1 ; i < 6 ; i += 2 )
      vaL [ i ] =  -100;
   for ( i = 0 ; i < 6 ; i++ )
      vaR [ i ] =  2*i;
   
   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;

   vaNE = ( vaL / vaR );
   cout << "The element-by-element result of "
        << "the quotient is the\n valarray: ( ";
      for ( i = 0 ; i < 6 ; i++ )
         cout << vaNE [ i ] << " ";
   cout << ")." << endl;
}
  
  
  

要求

标头: <valarray>

命名空间: std