文件名称:zuoye11
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:690byte
-
已下载:2次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
1.编写递归函数计算Fibonacci数列,能避免重复计算
输入:input.txt,仅包含一个整数n(0-90)
输出:程序应能检查输入合法性,若有错误,输出错误提示“WRONG”;否则输出F(n)。两种情况都输出一个回车(形成一个空行)。所有实例均应在30秒内输出结果。
提示:可用一数组保存Fibonacci数列,用一个特殊值表示还未计算出Fibonacci数,递归调用前先检查数组,若已计算,直接取用,不进行递归调用;若未计算,调用递归函数,计算完成后保存入数组。实际上,这种方法得到了F(1)-F(n),而不仅是F(n)。
另外,注意数据类型取值范围问题。VC 6.0中,长整型为LONGLONG,而其输出用 I64d。
-Write a recursive function calculation Fibonacci sequence, to avoid double counting input: input.txt contains only an integer n (0-90) output: the program should be able to check the input legitimacy, any errors in the output error " WRONG" Otherwise, output F (n). In both cases, output a carriage return (form a blank line). All instances should be within 30 seconds to output the result. Tip: available an array to save the Fibonacci sequence, with a special value that has not yet calculated the Fibonacci numbers, before the recursive call to check array, if you calculate, direct access to the recursive call if not calculated to call recursive function to calculate completed and saved into the array. In fact, this approach has been the F (1)-F (n), not only is F (n). In addition, note that the range of data types. VC 6.0, long integer LONGLONG, its output I64d.
输入:input.txt,仅包含一个整数n(0-90)
输出:程序应能检查输入合法性,若有错误,输出错误提示“WRONG”;否则输出F(n)。两种情况都输出一个回车(形成一个空行)。所有实例均应在30秒内输出结果。
提示:可用一数组保存Fibonacci数列,用一个特殊值表示还未计算出Fibonacci数,递归调用前先检查数组,若已计算,直接取用,不进行递归调用;若未计算,调用递归函数,计算完成后保存入数组。实际上,这种方法得到了F(1)-F(n),而不仅是F(n)。
另外,注意数据类型取值范围问题。VC 6.0中,长整型为LONGLONG,而其输出用 I64d。
-Write a recursive function calculation Fibonacci sequence, to avoid double counting input: input.txt contains only an integer n (0-90) output: the program should be able to check the input legitimacy, any errors in the output error " WRONG" Otherwise, output F (n). In both cases, output a carriage return (form a blank line). All instances should be within 30 seconds to output the result. Tip: available an array to save the Fibonacci sequence, with a special value that has not yet calculated the Fibonacci numbers, before the recursive call to check array, if you calculate, direct access to the recursive call if not calculated to call recursive function to calculate completed and saved into the array. In fact, this approach has been the F (1)-F (n), not only is F (n). In addition, note that the range of data types. VC 6.0, long integer LONGLONG, its output I64d.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
zuoye11.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.