# Include <iostream>
# Include <vector>
# Include <string>
# Include <iterator>
# Include <stdlib. h>
# Include <time. h>
Using namespace STD;
Template <class T>
Class lessthan
{
Public:
Virtual bool operator () (const T & one, const T & Other) = 0;
};
Template <class T>
Class lessthanofintdoublestring: Public lessthan <t> // for integers, floating-point numbers, and strings
{
Public:
Bool operator () (const T & one, const T & other)
{
Return one <Other;
}
};
Template <class T, class iterator>
Void max (const iterator & beg, const iterator & End, lessthan <t> & lessthan, T & maxvalue)
{
Maxvalue = * beg;
Iterator it;
For (IT = beg; it! = End; it ++)
{
If (* It> maxvalue) maxvalue = * it;
}
}
void main ()
{< br> const int n = 100;
vector A;
int I;
srand (unsigned) time (0);
for (I = 0; I {< br>. push_back (RAND () % N);
cout }< br> cout
int maxvalue;
MAX (. begin (),. end (), lessthanofintdoublestring (), maxvalue);
cout <"maximum value:"
}