Espacios de nombres
Variantes
Acciones

std::valarray::sum

De cppreference.com
< cpp‎ | numeric‎ | valarray
 
 
 
 
T sum()const;
Calcula la suma de los elementos .
Original:
Computes the sum of the elements.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
La función puede utilizarse únicamente si operator+= se define para T tipo. Si el std::valarray está vacío, el comportamiento es indefinido. El orden en que los elementos son procesados ​​por esta función no está especificado .
Original:
The function can be used only if operator+= is defined for type T. If the std::valarray is empty, the behavior is undefined. The order in which the elements are processed by this function is unspecified.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar]Parámetros

(Ninguno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Valor de retorno

La suma de los elementos .
Original:
The sum of the elements.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Ejemplo

#include <iostream>#include <valarray>   int main(){std::valarray<int> a ={1, 2, 3, 4, 5, 6, 7, 8, 9, 10};std::cout<< a.sum()<<'\n';}

Salida:

55

[editar]Ver también

applies a function to every element of a valarray
(función miembro pública)[editar]
Suma un rango de elementos
(plantilla de función)[editar]
close