当前位置:网站首页>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;
}
边栏推荐
- [cmake command notes]find_ path
- 魔王冷饭||#099 魔王说西游;老板的本质;再答中年危机;专业选择
- Game (sanziqi & minesweeping)
- MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)
- 278. digital combination
- Wechat mobile terminal development - account login authorization
- "Initial C language" (Part 2)
- Component development
- C. Number of Pairs-Codeforces Round #725 (Div. 3)
- 崔鹏团队:万字长文梳理「稳定学习」全景图
猜你喜欢

3D打印微组织

Detailed explanation of clip attribute parameters

Network module packaging

2022-1-12

Byte order: big endian vs little endian

Development status of full color LED display

Sfod: passive domain adaptation and upgrade optimization, making the detection model easier to adapt to new data

Unique in Pimpl_ PTR compilation errors and Solutions

Overview of visual object detection technology based on deep learning

Component development
随机推荐
Muduo simple usage
You can also do NLP (classification)
Pat class A - 1014 waiting in line (bank queuing problem | queue+ simulation)
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
9. class and object practice and initialization list
Overview of visual object detection technology based on deep learning
"First knowledge of C language" (Part 3)
1. introduction to MySQL database connection pool function technology points
SYSTEMd summary
[learning notes] roll back Mo team
SQL programming task04 job - set operation
Vector 1 (classes and objects)
C. Diluc and Kaeya——Codeforces Round #724 (Div. 2)
A hundred lines of code to realize reliable delay queue based on redis
Day575: divide candy
C. Unstable String
C# SerializableDictionary序列化/反序列化
使用aggregation API扩展你的kubernetes API
Use elk to save syslog, NetFlow logs and audit network interface traffic
Lexical Sign Sequence