Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Calculer la somme d’un tableau de ‘double’

 calcul, accumulate
{filelink=15266}

#include <iostream>
#include <numeric>
#include <functional>
using namespace std;
 
int main()
{
   double tab[4] = {2.3, 4.2, 1.3, 3.2};
   double  resultat;
 
   resultat = accumulate(tab, tab + 4, 0.0, minus<double>());
   cout << "Résultat = " << resultat << endl;
 
   return 0;
}

No comments yet.

Leave a Comment