Fibonacci()函数
提示: 作者被禁止或删除 内容自动屏蔽
int i,a=0,b=1,fnum=23;//fnum为第几项 for (i = 0; i < fnum; i++) { b = a + b; a = b - a; } b就是结果了
#include <stdio.h> void main() { int i=0,a=0,b=1,fnum=22; /*fnum为第几项,22是int最大范围了*/ for (;i<=fnum;b+=a,a=b-a) printf("f(%d)=%d\n",i++,b); getch(); }