编写函数jsValue,功能:求Fibonacci数列中大于t的第一个数,结果由函数返回。

其中Fibonacci数列F(n)的定义为:
1,1,2,3,。。。。。最后调用函数writeDat()读取10个任意数据t,分别得出结果且把结果输出到一个数组当中。
例如:当t=1000时,函数值为:1597。

c还是 。。。c++

#include<stdio.h>
int  jsValue(int n){
int a=1;
int b=1;
int s=1;
while(1){
if(n<s)
return b;
else
{
s=a+b;
a=b;
b=s;
}
}
}
int main(){
int s;
scanf("%d",&s);
printf("%d",jsValue(s));
return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-06-10
你是昆工的吧,题目和我的一模一样
相似回答