问题九十:Fibonacci数用数组(续问题八十八)
[plain]
#include <stdio.h>
int main()
{
int i;
int array[100];
int num;
printf("please enter a number:");
scanf("%d", &num);
array[0]= array[1]=1;
for(i=2; i<num; i++)
{
array[i]=array[i-1]+ array[i-2];
}
printf("The result is %d\n", array[num-1]);
return 0;
}
#include <stdio.h>
int main()
{
int i;
int array[100];
int num;
printf("please enter a number:");
scanf("%d", &num);
array[0]= array[1]=1;
for(i=2; i<num; i++)
{
array[i]=array[i-1]+ array[i-2];
}
printf("The result is %d\n", array[num-1]);
return 0;
}
补充:软件开发 , C语言 ,