斐波那契数列
2015-09-08 12:13
357 查看
时间限制:1秒空间限制:32768K
通过比例:25.92%
最佳记录:0 ms|3156K (来自 知否)
题目描述
大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项。
斐波那契数列:
通过比例:25.92%
最佳记录:0 ms|3156K (来自 知否)
题目描述
大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项。
class Solution { public: int Fibonacci(int n) { if(n == 0 ) { return 0; } else if(n == 1) { return 1; } else {} int a = 0, b = 1, num, i; for(i = 2; i <= n; i++) { num = a + b; a = b; b = num; } return num; } };
斐波那契数列:
0,1,1,2,3,5,8......
相关文章推荐
- !function(),+function()
- SVN状态图标消失的解决办法
- Memcached和Memcache安装(64位win7)
- 部分浏览器上a标签包裹的dom元素显示不正常
- 如何监控ActiveMQ
- 简单 python爬虫 <2>
- 交换、路由与防火墙手记(4)
- 学习排序算法
- LeetCode 219. Contains Duplicate II
- leetCode #144 Binary Tree Preorder Traversal
- dota war3map.j 解读
- c#获取页面重定向url
- 《用流程解放管理者》读后感
- LeetCode 216. Combination Sum III
- cisco路由配置dhcp
- ImageNet Classification with Deep Convolutional Neural Networks(阅读)
- DELPHI - How to use opendialog1 for choosing a folder? TOpenDialog, TFileOpenDialog
- ceph之纠删码
- 加入一个新的圈子,去谈论知识
- 在CentOS 6.3 64bit上安装redis 3.0.3