64,685
社区成员
发帖
与我相关
我的任务
分享
template <typename int n>
struct Factorial
{
enum {val = Factorial<n-1>::val * n};
};
template <>
struct Factorial<0>
{
enum {val = 1};
};
int x = Factorial<10>::val;
00411E0E mov dword ptr [x],375F00h
int y=0;
cin>>y;
Factorial<y>::val;
//获取数组元素个数
template<typename T,int n>
int sizeofx(T (&arr)[n])
{
return n;
}
//简单2进制
template<int n>
struct binaryx_
{
enum{value = n % 10 + binaryx_<n / 10>::value * 2};
};
template<>
struct binaryx_<0>
{
enum{value = 0};
};