/* Lecture code 7.1
 *
 * count_if using functors.
 */

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;

const int NUM_ELEMENTS = 10000;

/* Tells if one element is greater than another - in two weeks we'll see an even cooler way to do this. */
class GreaterThan
{
public:
	/* Constructor - see Handout 17 for explicit. */
	explicit GreaterThan(int maxValue) : threshold(maxValue) {}
	bool operator () (int value) const
	{
		return value > threshold;
	}
private:
	const int threshold;
};

int main()
{
	srand((unsigned int)time(NULL)); // Seed the randomizer using the current time.
	
	/* Fill the vector with random numbers using generate_n and a back_inserter. */
	vector<int> myVector;
	generate_n(back_inserter(myVector), NUM_ELEMENTS, rand);
	
	/* Prompt the user (though we should most certainly be using GetInteger here. */
	int cutoff;
	cin >> cutoff;
	
	/* Print the number of elements greater than the value.  We're using the temporary object syntax here. */
	cout << count_if(myVector.begin(), myVector.end(), GreaterThan(cutoff)) << endl;
	
	return 0;
}