Skip to content

Instantly share code, notes, and snippets.

@plonk
Last active December 20, 2015 01:29
Show Gist options
  • Select an option

  • Save plonk/6049392 to your computer and use it in GitHub Desktop.

Select an option

Save plonk/6049392 to your computer and use it in GitHub Desktop.
匿名再帰
#include <iostream>
#include <functional>
using namespace std;
int main()
{
function<int(int)> fac = [&] (int n)
{
if (n == 1)
return 1;
else
return n * fac(n-1);
};
cout << fac(5) << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment