文件名称:zuoye11
介绍说明--下载内容均来自于网络,请自行研究使用
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