#include <iostream>
#include <cstring>
using namespace std;
template<int size, class T>
T min2(T* a)
{
cout << "min<T>" << endl;
T m = a[0];
for (int i = 0; i < size; i++)
if(a[i] < m) m = a[i];
return m;
}
template<int size>
char* min2(char** a)
{
cout << "min<char*>" << endl;
char* m = a[0];
for (int i=0; i < size; i++)
if (strcmp(a[i], m) < 0) m = a[i];
return m;
}
int main()
{
int ia[] = { 0, 1 };
int imin = min2<2, int>(ia);
cout << "imin = " << imin << endl;
char* is[] = { "0", "1" };
char* smin = min2<2>(is);
cout << "smin = " << smin << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnRlbXBsYXRlPGludCBzaXplLCBjbGFzcyBUPgpUIG1pbjIoVCogYSkKewoJY291dCA8PCAibWluPFQ+IiA8PCBlbmRsOwogICAgVCBtID0gYVswXTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgc2l6ZTsgaSsrKQogICAgICAgIGlmKGFbaV0gPCBtKSBtID0gYVtpXTsKICAgIHJldHVybiBtOwp9Cgp0ZW1wbGF0ZTxpbnQgc2l6ZT4KY2hhciogbWluMihjaGFyKiogYSkKeyAgICAgICAgICAgICAgICAgICAgICAgICAgIAoJY291dCA8PCAibWluPGNoYXIqPiIgPDwgZW5kbDsKICAgIGNoYXIqIG0gPSBhWzBdOyAgICAgICAgICAgIAogICAgZm9yIChpbnQgaT0wOyBpIDwgc2l6ZTsgaSsrKSAgIAogICAgICAgIGlmIChzdHJjbXAoYVtpXSwgbSkgPCAwKSBtID0gYVtpXTsKICAgIHJldHVybiBtOwp9CgppbnQgbWFpbigpCnsKCWludCBpYVtdID0geyAwLCAxIH07CiAgICBpbnQgaW1pbiA9IG1pbjI8MiwgaW50PihpYSk7CiAgICBjb3V0IDw8ICJpbWluID0gIiA8PCBpbWluIDw8IGVuZGw7CgoJY2hhciogaXNbXSA9IHsgIjAiLCAiMSIgfTsKICAgIGNoYXIqIHNtaW4gPSBtaW4yPDI+KGlzKTsKICAgIGNvdXQgPDwgInNtaW4gPSAiIDw8IHNtaW4gPDwgZW5kbDsKCQoJcmV0dXJuIDA7Cn0=