Beispiel #1
0
int main()
{
    vector<int> coll = { 1, 2, 3, 4, 5, 6, 7, 8 };

    // process and print mean value
    MeanValue mv = for_each (coll.begin(), coll.end(),  // range
                             MeanValue());              // operation
    cout << "mean value: " << mv.value() << endl;
}
Beispiel #2
0
int main(int argc, char *argv[])
{
  vector<int> v1;

  populate_rand(v1, 10, 100);
  print_seq(v1, "v1 : ");
  MeanValue mv = for_each(v1.begin(), v1.end(),
			  MeanValue());
  cout << "count " << mv.numValues() << "mean " << mv.value() << endl;
  return 0;
}
Beispiel #3
0
int main()
{
	vector<int> coll;
	for(int i=1; i<=8; ++i)
	{
		coll.push_back(i); 
	}
	copy(coll.begin(),coll.end(),ostream_iterator<int>(cout," "));
	cout<< endl;
	MeanValue mv = for_each (coll.begin(),coll.end(),MeanValue());
	cout << "meanValue: " << mv.value() << endl;
}