2025-03-06 23:47:59 +08:00

26 lines
631 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.

/*------------------------------------------------------------------------
【程序设计】功能使用for循环输出Fibonacci数列的前15项要求每行输出5项。
Fibonacci数列1,1,2,3,5,8,13...........
----------------------------------------------------------------------*/
#include <stdio.h>
main()
{
int fib[15],i;
fib[0]=1;fib[1]=1;
/**********Program**********/
for(i=2;i<15;i++){
fib[i]=fib[i-1]+fib[i-2];
}
/********** End **********/
for(i=0;i<15;i++)
{
printf("%d\t",fib[i] );
if ( i%5==4 ) printf("\n");
}
}