實現斐波那契數列
#include<bits/stdc++.h>
using namespace std;
auto adder() {
auto a = 0, b = 1;
return [=]() mutable {
b = a + b;
a = b - a;
return a;
};
}
int main() {
auto f = adder();
cout << f() << endl;
cout << f() << endl;
cout << f() << endl;
cout << f() << endl;
cout << f() << endl;
cout << f() << endl;
cout << f() << endl;
system("pause");
return 0;
}