71.lambda表达式的递归

 1 #include <iostream>
 2 #include <functional>
 3 using namespace std;
 4 
 5 void main()
 6 {
 7     //&调用外部
 8     //function<void(void)> fun = [&]()->void {cout << "hello" << endl; fun(); };
 9     function<void(int)> fun = [&](int i)
10     {
11         if (i == 0)
12         {
13             return 0;
14         }
15         else
16         {
17             cout << i << endl;
18             fun(i-1);
19         }
20     };
21     fun(100);
22     system("pause");
23 }

 

posted @ 2018-03-15 16:16  喵小喵~  阅读(163)  评论(0编辑  收藏  举报