首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

编程技艺:lambda与递归

2012-07-30 
编程技巧:lambda与递归以下代码演示如何使用lambda来定义阶乘这一递归函数。C##include functionalfuncti

编程技巧:lambda与递归
以下代码演示如何使用lambda来定义阶乘这一递归函数。
C#

#include <functional>function<int(int)> factorial = [&](int x){return x == 0 ? 1 : x * factorial(x - 1);};int f5 = factorial(5); // f5 == 120

热点排行