当前位置:网站首页>Non recursive printing Fibonacci sequence
Non recursive printing Fibonacci sequence
2022-06-22 05:07:00 【Jiangxueqian】
#include <stdio.h>
int main()
{
int n; // The number of elements of the sequence to be printed
int a = 1, b = 1; // The initial values of the first and second terms of the sequence
int c = 0; // Array element values
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
if (i == 1 || i == 2)
{
printf("%-3d\t", 1);
}
else
{
c = a + b; // The third is the sum of the first two
printf("%-3d\t", c); // Output the third item
a = b; // The original second item becomes the new first item
b = c; // The original third item becomes the new second item
}
}
return 0;
}flow chart :
边栏推荐
- ORA-15063: ASM discovered an insufficient number of disks for diskgroup 恢複---惜分飛
- DeformConv
- 并发编程——线程池
- [chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)
- Hash type of redis
- How to display loading animation when requesting data
- [camp] at the beginning, improve [leopard] power - vivo activity plug-in management platform
- NLP 的 不可能三角?
- Solutions to MySQL 8.0 public key retrieval is not allowed errors
- 新建本地内容上传至码云分支
猜你喜欢

How much is London gold

Postman document parameterization

10道不得不会的 Redis 面试题

Arrangement of soft test subjects in the second half of 2022

Ora-15063: ASM discovered an insufficient number of disks for diskgroup

Software architecture and pattern: structure, component and relationship

加快推进工业互联网,图扑“智”绘发展新蓝图

这是一个图片

Disturbed when programmers are programming? Daily anecdotes

【科研笔记】Focal Loss
随机推荐
laravel的服务容器,服务提供者,门面的理解
[chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)
CS 611 Game
Will swift compile to native code- Does Swift compile to native code?
Data backup and recovery
Final examination questions of Database Principles
89---狄拉克 delta 函数
Importbeandefinitionregistrar registers beans with the container
数据库---基础知识
In depth understanding of JS delete
C语言数据类型转换规则(隐式转换+显式转换)
How to deal with too small picture downloaded from xuexin.com
数据的备份与恢复
C语言变量的存储方式和生存期
C语言字符串的一些使用注意事项
MySQL day04 class notes
【科研笔记】Focal Loss
Pull down refresh, push up load (easy to use, finally)
Great! Huaibei and Huaibei enterprises are approved to use special marks for geographical indication products
In 2022, the super intern plans to make a breakthrough in the offer of it famous enterprises, and the nine high salary skills help the dream of famous enterprises