#include <vector>
#include <iostream>
using namespace std;
#include "max-min.h"

class CountingComparator {   
// implements a < b on floats, and counts how many times < is called.
    public:
	CountingComparator(): count(0) {};
	CountingComparator(const CountingComparator& lt): count(lt.count) {};

	bool operator()(float a, float b){ 
		++count; 
		return a < b; 
	}

	int comparisons(){ return count; }
	void reset(){ count = 0; }
    private:
	int count;
};

main()
{	float x;
	vector<float> V;
	while (cin >> x) V.push_back(x); 
	for(int i = 0; i < V.size(); ++i) cout << V[i] << " "; cout << endl << endl;;

	CountingComparator lt;
	max_min_1(V.begin(), V.size(), lt);
	cout << "max-min_1 called, used " << lt.comparisons() << " comparisons." << endl;
	for(int i = 0; i < V.size(); ++i) cout << V[i] << " "; cout << endl << endl;;

	lt.reset();
	max_min_2(V.begin(), V.size(), lt);
	cout << "max-min_2 called, used " << lt.comparisons() << " comparisons." << endl;
	for(int i = 0; i < V.size(); ++i) cout << V[i] << " "; cout << endl << endl;;

	lt.reset();
	max_min_3(V.begin(), V.size(), lt);
	cout << "max-min_3 called, used " << lt.comparisons() << " comparisons." << endl;
	for(int i = 0; i < V.size(); ++i) cout << V[i] << " "; cout << endl << endl;;
}

