问题八十八:Fibonacci数非递归解
[plain]
#include <stdio.h>
int main()
{
int i;
int a;
int b;
int c;
int n;
printf("please enter a number:");
scanf("%d", &n);
a=b=1;
for(i=3; i<=n; i++)
{
c=a+b;
a=b;
b=c;
}
printf("The result is %d\n", c);
return 0;
}
#include <stdio.h>
int main()
{
int i;
int a;
int b;
int c;
int n;
printf("please enter a number:");
scanf("%d", &n);
a=b=1;
for(i=3; i<=n; i++)
{
c=a+b;
a=b;
b=c;
}
printf("The result is %d\n", c);
return 0;
}
补充:软件开发 , C语言 ,