???
2024-05-12 16:20:57
发布于:上海
10阅读
0回复
0点赞
#include <iostream>
using namespace std;
int fibonacci(int n) {
if (n <= 1) {
return n;
}
int a = 0, b = 1;
for (int i = 2; i <= n; ++i) {
int temp = b;
b = a + b;
a = temp;
}
return b;
}
int main() {
int N;
cin >> N;
cout << fibonacci(N) << endl;
return 0;
}
这里空空如也
有帮助,赞一个