复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32int Fib(int n) { if (n == 1) { return 0; } if (n == 2) { return 1; } int f1 = 0; int f2 = 1; int c = 0; for (int i = 3; i <= n; i++) { c = f1 + f2; f1 = f2; f2 = c; } return c; } int main() { int n; scanf("%d", &n); int ret=Fib(n); printf("%d", ret); system("pause"); return 0; }
最后
以上就是烂漫煎饼最近收集整理的关于coding A&D:斐波那契数列:非递归实现的全部内容,更多相关coding内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复