2025-03-06 12:46:40 +08:00

31 lines
642 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
斐波那契数列的前几项是1、1、2、3、5、8、13、21……编程输出该数列直到某项的值大于10000为止每行输出4个。
结果:
1 1 2 3
5 8 13 21
34 55 89 144
233 377 610 987
1597 2584 4181 6765
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int a,b,c,i;
a=b=1;
printf("%d\t%d\t",a,b);
for(i=3;;i++)
{
c=a+b;
if(c>10000)
break;
printf("%d\t",c);
/**********Program**********/
if(i%4==0){
printf("\n");
}
a = b;
b = c;
}
/********** End **********/
}