Exemple d’utilisation de la fonction template ‘inner_product()’

Author:


Download


#include 
#include 
#include 
#include 
using namespace std;

int main()
{

  int tab1[10], tab2[10];

  for (int i = 0; i < 10; ++i) {
    tab1[i] = i + 1;
    tab2[i] = i + 2;
  }

  /*
    la fonction inner_product applique sur le
	rang spécifié, la formule suivante:

	 init=init+(*iter1)*(*iter2)

  */
  int resultat = inner_product(&tab1[0], &tab1[10], &tab2[0],1);

  cout << "Résultat: " << resultat << endl;

  return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *