#include <iostream>
template<typename A, typename B, typename C>
C mymin (const A& a, const B& b)
{
if ( a < b )
return (C) a;
else
return (C) b;
}
int main()
{
double val1 = 66.8, val2 = 75.4 ;
std::cout << "min of " << val1 << " and " << val2 << " is: "
<< mymin<int,double,double>( val1, val2 ) << '\n' ;
std::cout << "min of " << val1 << " and " << val2 << " is: "
<< mymin<double,int,double>( val1, val2 ) << '\n' ;
std::cout << "min of " << val1 << " and " << val2 << " is: "
<< mymin<double,double,char>( val1, val2 ) << '\n' ;
char a[] = "12345", b[] = "abcde" ;
std::cout << "min of " << a << " and " << b << " is: "
<< mymin<char*,char*,char*>( a, b ) << '\n' ;
char c[] = "abcde", d[] = "12345" ;
std::cout << "min of " << c << " and " << d << " is: "
<< mymin<char*,char*,char*>( c, d ) << '\n' ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGU8dHlwZW5hbWUgQSwgdHlwZW5hbWUgQiwgdHlwZW5hbWUgQz4KQyBteW1pbiAoY29uc3QgQSYgYSwgY29uc3QgQiYgYikKewogIGlmICggYSA8IGIgKQogICAgICByZXR1cm4gKEMpIGE7CiAgZWxzZQogICAgICByZXR1cm4gKEMpIGI7Cn0KCmludCBtYWluKCkKewogICAgZG91YmxlIHZhbDEgPSA2Ni44LCB2YWwyID0gNzUuNCA7CgogICAgc3RkOjpjb3V0IDw8ICJtaW4gb2YgIiA8PCB2YWwxIDw8ICIgYW5kICIgPDwgdmFsMiA8PCAiIGlzOiAiCiAgICAgICAgICAgICAgIDw8IG15bWluPGludCxkb3VibGUsZG91YmxlPiggdmFsMSwgdmFsMiApIDw8ICdcbicgOwoKICAgIHN0ZDo6Y291dCA8PCAibWluIG9mICIgPDwgdmFsMSA8PCAiIGFuZCAiIDw8IHZhbDIgPDwgIiBpczogIgogICAgICAgICAgICAgICA8PCBteW1pbjxkb3VibGUsaW50LGRvdWJsZT4oIHZhbDEsIHZhbDIgKSA8PCAnXG4nIDsKCiAgICBzdGQ6OmNvdXQgPDw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