operator%
Uzyskuje reszta z podzielenia odpowiednie elementy o dwóch valarrays równe podzielenie valarray przez określoną wartość lub z podzielenia wartości określonej przez 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
);
Parametry
_Left
Wartość lub valarray lub valarray, który służy jako dywidendy na inną wartość, która jest podzielony._Right
Wartość lub valarray, który służy jako dzielnik i która dzieli inną wartość lub valarray.
Wartość zwracana
Valarray, której elementy są reszty element-wise z _Left podzielona przez_Right.
Przykład
// 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;
}
Wymagania
Nagłówek: <valarray>
Obszar nazw: std