斐波纳契数 [英] Fibonacci number
问题描述
如何在C中生成fibonacci mubers?
How to generate fibonacci mubers in C ?
推荐答案
2004年2月22日07:59:08 -0800, ju ***** @ yahoo.com (jugaaru)写道:
On 22 Feb 2004 07:59:08 -0800, ju*****@yahoo.com (jugaaru) wrote:
如何生成fibonacci mubers in C?
How to generate fibonacci mubers in C ?
至少有两种方式:迭代(创建一个数组,然后在运行中填充它们)或递归(有一个函数返回0和1为第一个
两个斐波那契数字,然后通过调用
本身来计算任何其他数据来获得前两个。注意那里' 'sa / serious /
第二种技术的性能下降,但代码更有趣
;-)
-leor
Leor Zolman
BD软件
le**@bdsoft.com
www.bdsoft.com - C / C ++,Java现场培训,Perl& Unix
C ++用户:下载BD Software的免费STL错误消息
Decryptor at www.bdsoft.com/tools/stlfilt.html
At least two ways: iteratively (create an array, and populate it
on-the-fly), or recursively (have a function return 0 and 1 for the first
two Fibonacci numbers, and then have it calculate any other by calling
itself to acquire the previous two. Note that there''s a /serious/
performance degradation for the 2nd technique, but it is more fun to code
;-)
-leor
Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software''s free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
jugaaru写道:
jugaaru wrote:
如何在C中生成fibonacci mubers?
How to generate fibonacci mubers in C ?
算法是
F( n + 1)= F(n)+ F(n-1),F(0)= 0,F(1)= 1
你可以递归地执行此操作(非常愚蠢慢 - 请参阅我的文章
Recurses!在计算机科学与工程中)或迭代地
(更好)。
>
我不会告诉你怎么做,因为它显然是家庭作业。
Julian V. Noble
物理荣誉教授
jv*@lessspamformother.virginia.edu
^^^^^^^^^ ^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/
因为有从来没有哲学家耐心地耐受
牙痛。
- Wm。莎士比亚,很多阿多无所事事。法案诉Sc。 1.
The algorithm is
F(n+1) = F(n) + F(n-1) , F(0) = 0, F(1) = 1
You can do this recursively (very stupid and slow--see my article
"Recurses!" in Computing in Science and Engineering) or iteratively
(much better).
I won''t tell you how to do it since it is evidently homework.
Julian V. Noble
Professor Emeritus of Physics
jv*@lessspamformother.virginia.edu
^^^^^^^^^^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/
"For there was never yet philosopher that could endure the
toothache patiently."
-- Wm. Shakespeare, Much Ado about Nothing. Act v. Sc. 1.
" jugaaru" <菊***** @ yahoo.com>在消息中写道
news:d7 ************************** @ posting.google.c om ...
"jugaaru" <ju*****@yahoo.com> wrote in message
news:d7**************************@posting.google.c om...
如何在C中生成fibonacci mubers?
How to generate fibonacci mubers in C ?
#include< stdio.h>
int main(){
printf(" fibonacci mubers in C\ n);
返回0;
}
#include <stdio.h>
int main() {
printf("fibonacci mubers in C\n");
return 0;
}
这篇关于斐波纳契数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!