计算阶乘,你见过这样的么?
2011-12-09 11:41
232 查看
//TMP(模板元编程),计算阶乘 #include <iostream> using namespace std; template <unsigned n> struct Factorial { enum { value = n * Factorial<n - 1>::value }; }; //偏特化 template <> struct Factorial<0> { enum { value = 1 }; }; int main() { cout << Factorial<5>::value << endl; cout << Factorial<10>::value << endl; return 0; }
相关文章推荐
- 计算n的阶乘
- 蓝桥杯 基础练习 阶乘计算
- 计算阶乘 用循环实现
- 用递归法计算阶乘
- 阶乘计算
- 基础练习 阶乘计算
- 大数阶乘的位数和精确值计算
- 用十进制计算30!(30的阶乘),将结果转化成3进制进行表示的话,该进制下的结果末尾会有多少个0?
- JavaSE8基础 BigInteger 使用递归函数来计算阶乘
- 蓝桥杯阶乘计算
- 基础练习 阶乘计算
- 数学问题——用递归计算阶乘
- LeetCode Factorial Trailing Zeroes(计算阶乘结果尾部有几个0)
- 计算阶乘n!末尾所含0的个数
- 云计算之我见――杀手级应用”是这样炼成的
- [深入Python]简单事情复杂化:Python计算阶乘
- L1-013. 计算阶乘和
- 计算n阶乘中尾部零的个数
- 计算大数阶乘--Python版
- 作业4.5-3 计算1到20阶乘倒数之和