码迷,mamicode.com
首页 > 编程语言 > 详细

C语言学习(3)

时间:2018-06-24 11:39:02      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:...   int   stdio.h   ++   技术   include   span   AC   image   

 1 //输出Fibonacci数列1,1,2,3,5,8,13,21,...的前40项
 2 //经过观察,我们可以得出结论后一项是前两项之和
 3 #include <stdio.h>
 4 int main(){
 5     int a,b,c;
 6     a=1;
 7     b=1;
 8     c=a+b;
 9     int sum=a;
10     for(int i=1;i<5;i++){
11         a=b;
12         b=c;
13         c=a+b;
14         sum+=a;
15     }
16     printf("%d\n",sum);
17     return 0;
18 }

技术分享图片

C语言学习(3)

标签:...   int   stdio.h   ++   技术   include   span   AC   image   

原文地址:https://www.cnblogs.com/Tobi/p/9219774.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!