https://www.cnblogs.com/longhai3/longhai

C语言>>斐波那契数列

Posted on 2022-02-12 19:29  凡是过去,皆为序曲  阅读(8)  评论(0编辑  收藏  举报

#include<stdio.h>
int main()
{
int a=1,b=1,c=3,d;
printf("%d %d ",a,b);
while(c<=18)
{
d=a+b;
printf("%d ",d);
if(c%6==0)
{
printf("\n");
}
a=b;
b=d;
c=c+1;
}
return 0;
}

==============================================

#include<stdio.h>
int main()
{
int a=1,b=1,c=0,d;
printf("%d,%d,",a,b);
for(d=3;d<=18;d++)
{
c=a+b;
printf("%d,",c);
a=b;
b=c;
if(d%6==0)
{printf("\n");}
}
return 0;
}

 

随心,随记

https://www.cnblogs.com/w1hg/331817