Exemple d’utilisation de compteur avec prédicat ‘count_if()’

Author:

 assert
{filelink=15277}


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

int main()
{
  int tab[] = {6, 6, 4, 1, 1, 1, 2, 2, 2};

  // Compter le nombre d'éléments différent de 2
  int nbr = count_if(&tab[0], &tab[9], bind2nd(not_equal_to(), 2));

  cout << nbr << endl;
  return 0;
}

Leave a Reply

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