| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 555 人关注过本帖
标题:[求助]刚学C遇到无法解的题了啊 函数这一章的
只看楼主 加入收藏
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
 问题点数:0 回复次数:4 
[求助]刚学C遇到无法解的题了啊 函数这一章的
要求通过填空使下列程序段A与B功能等价
程序段A:
int f(int n)
{
if(n<=1)return n;
else return f(n-1)+f(n-2);
}

程序段B:
int f(int n)
{
_________;

t0=0;t1=1;t=n;

while(________)

{

t=________;

t0=t1;

t1=t;

n--;

}

return__________;

}


怎么看也无法使B与A等效啊
搜索更多相关主题的帖子: 函数 
2005-04-27 22:07
jiely
Rank: 1
等 级:新手上路
帖 子:106
专家分:0
注 册:2004-5-15
收藏
得分:0 
int t0,t1,t;
n>-1
t0+t1
t

我的爱好:C和数据库!正在学VC++ 我的QQ:345895839,有共同爱好的加我!期待着与你共同进步!
2005-04-27 22:27
空前
Rank: 1
等 级:新手上路
帖 子:1146
专家分:0
注 册:2004-5-11
收藏
得分:0 
int f(int n)
{
_________;

t0=0;t1=1;t=n;

while(____n____)

{

t=___t1+t0_____;

t0=t1;

t1=t;

n--;

}

return_______t___;

}

2005-04-27 22:28
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 
搞懂了 这是求菲波那契序列的 每项等于前两项之和 谢谢各位的帮助

/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-04-28 00:41
xiaodongcd
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-4-27
收藏
得分:0 
我也终于看懂了,想了半天才搞明白,看来我的道行还是不够,继续努力

2005-04-28 10:00
快速回复:[求助]刚学C遇到无法解的题了啊 函数这一章的
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013085 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved