#include <iostream>
#include <string>
template<int T>
std::string StrangeFunc()
{
return StrangeFuncStruct<T>::value();
}
template<int T, bool lt16 = (T<16)>
struct StrangeFuncStruct
{
static std::string value()
{
return StrangeFuncStruct<T, (T<16)>::value();
}
};
template<int T>
struct StrangeFuncStruct<T, true>
{
static std::string value()
{
return std::string(1, T + ((T>9)?'A'-10:'0'));
}
};
template<int T>
struct StrangeFuncStruct<T, false>
{
static std::string value()
{
return StrangeFuncStruct<(T/16)>::value()
+ StrangeFuncStruct<(T%16)>::value();
}
};
int main()
{
std::cout << StrangeFunc<137+137*256>() << std::endl;
}
Login in to like
Login in to comment