当前位置:网站首页>Three methods for solving Fibonacci sequence feibonacci (seeking rabbit) - program design
Three methods for solving Fibonacci sequence feibonacci (seeking rabbit) - program design
2022-06-23 01:45:00 【kalada82】
1,1,2,3,5,8,13,,,,,
This is it. feibonaci Count
F1=1,n=1
f2=1,n=2
fn=fn-1+fn-2,n=3
To put it simply , Programming ;
data type ( It is important to understand the principle , It is very helpful to understand why it is written in this form )
( operation , data ) Definition of variables ( Determination of needs )
( Various ) The determination of boundaries ( The starting point ,, End )
Determination of process ( Split of steps , Determine the basic operation )
Key conditions ( The border ) The determination of ( Branch ?)
// loop - Reuse variables
// Basics 3 Variable
#include<stdio.h>
int main()
{
int f1=1,f2=1,f3;
int i;
printf("%l2\n%l2d\n",f1,f2);
for(i=1;i<=38;i++)
{
f3=f1+f2;
printf("%ld\n",f3);
f1=f2;
f2=f3;
}
return 0;
}

//for Cycle optimization ,2 Variable version
#include<stdio.h>
int main()
{
int f1=1,f2=1;
int i;
for(i=1;i<=20;i++)
{
printf("%l2d %l2d",f1,f2);
if(i%2==0)printf("\n");
f1=f1+f2;
f2=f2+f1;
}
return 0;
}

// Find one-dimensional array of rabbits
#include<stdio.h>
int main()
{
int i;
int f[20]={
1,1
};
for(i=2;i<20;i++)
f[i]=f[i-2]+f[i-1];
for(i=0;i<20;i++)
{
if(i%5==0)printf("\n");// Format control
printf("%12d",f[i]);
}
printf("\n");
return 0;
}
// Find one-dimensional array of rabbits
#include<stdio.h>
int main()
{
int i;
int f[20]={
1,1
};
for(i=2;i<20;i++)
f[i]=f[i-2]+f[i-1];
for(i=0;i<20;i++)
{
if(i%5==0)printf("\n");// Format control
printf("%12d",f[i]);
}
printf("\n");
return 0;
}
边栏推荐
- LeetCode 206. 反转链表(迭代+递归)
- 魔王冷饭||#099 魔王说西游;老板的本质;再答中年危机;专业选择
- 关于打算做一个web的问题看板,需要使用哪些方面语言及数据库知识!
- Extend your kubernetes API using the aggregation API
- Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
- Branch and loop statements (including goto statements) -part1
- [cmake command notes]target_ compile_ options
- SYSTEMd summary
- How to type Redux actions and Redux reducers in TypeScript?
- ERROR { err: YAMLException: end of the stream or a document separator is expected at line 6, colum
猜你喜欢

LeetCode 206. Reverse linked list (iteration + recursion)

Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
![[Title Fine brushing] 2023 Hesai FPGA](/img/e8/d9d8c549a4fee529b69ebfc9a9d6ef.png)
[Title Fine brushing] 2023 Hesai FPGA

A hundred lines of code to realize reliable delay queue based on redis

The devil cold rice # 099 the devil said to travel to the West; The nature of the boss; Answer the midlife crisis again; Specialty selection

Template specialization template <>

Freshman C language summary post (hold change) Part 2 formatted monthly calendar

Xiaobai operates win10 to expand Disk C (allocate disk D memory to Disk C) and the test is valid for many times

Use elk to save syslog, NetFlow logs and audit network interface traffic

Binary String
随机推荐
Found several packages [runtime, main] in ‘/usr/local/Cellar/go/1.18/libexec/src/runtime;
You can also do NLP (classification)
A blog allows you to understand the use of material design
3D打印微组织
Day575: divide candy
[Title Fine brushing] 2023 Hesai FPGA
Exercise analysis summary
[hdu] p7058 ink on paper finding the maximum edge of the minimum spanning tree
LeetCode 206. Reverse linked list (iteration + recursion)
Autumn move script a
Foundation Consolidation - Flex width is content width
Debian10 configuring rsyslog+loganalyzer log server
9. class and object practice and initialization list
C language student achievement ranking system
Openvino CPU acceleration survey
Pat class A - 1013 battle over cities
Const defined variables and for of and for in in JS
Uint8 serializing and deserializing pits using stringstream
Summary of the first week of winter vacation
Google benchmark user manual and examples