Sign in

gwj / po_oopc · Files

GitLab

  • Go to dashboard
  • Project
  • Activity
  • Files
  • Commits
  • Network
  • Graphs
  • po_oopc
  • examples09
  • 04-functionobject
  • fun1.cpp
  • Added foreach example
    8e894b70
    Grzegorz Jabłoński authored
    2019-12-11 18:48:43 +0100  
    Browse File »
fun1.cpp 334 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
using namespace std;


bool GTRM(long val) 
{ 
    return val > (RAND_MAX >> 1);
}

int
main ()
{
  srandom(time(NULL));
  vector < long > v(10);
  generate(v.begin(),v.end(),random);
  cout << count_if(v.begin(),v.end(),GTRM)<<endl;
};