1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
大蒟蒻 920a583abc
Wed, 11 Mar 2020 19:37:48 +0800
6 years ago
..
K_Fib.h Wed, 11 Mar 2020 19:37:48 +0800 6 years ago
Queue.h Wed, 11 Mar 2020 19:37:48 +0800 6 years ago
Recursive.h Wed, 11 Mar 2020 19:37:48 +0800 6 years ago
SeqQueue.h Wed, 11 Mar 2020 19:37:48 +0800 6 years ago
Test.cpp Wed, 11 Mar 2020 19:37:48 +0800 6 years ago
hw6.sln Wed, 11 Mar 2020 19:37:48 +0800 6 years ago
hw6.vcxproj Wed, 11 Mar 2020 19:37:48 +0800 6 years ago
readme.txt Wed, 11 Mar 2020 19:37:48 +0800 6 years ago

readme.txt

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

数据结构 作业6

目标:本次作业练习递归问题的求解和队列的应用。


开始:

1解压hw6.rar得到hw6文件夹。在hw6文件夹中
    Queue.h包含队列的虚基类
    Recursive.h包含正整数输出PrintOut递归函数
    K_Fib.h包含K阶斐波那契序列输出K_Fib函数
    SeqQueue.h包含顺序循环队列数据结构SeqQueue类
    测试文件Test.cpp的main函数包括测试正整数输出递归函数的代码和测试K阶斐波那契序列计算器的代码。

2建立一个空项目添加Queue.h、Recursive.h、K_Fib.h、SeqQueue.h头文件以及Test.cpp源文件。

3你的第一个任务

    在Recursive.h文件中PrintDigit()函数实现将单个数字(0-9)输出。设n是一个正整数其位数不确定请编写PrintOut()通过调用PrintDigit()函数实现输出正整数n要求PrintOut函数用递归函数实现。

4你的第二个任务:

    在K_Fib.h文件中K_Fib()函数实现计算并输出K阶斐波那契序列f0,f1,…,fn其中该序列最大项fn小于或等于max而第n+1项大于max。算法要求仅采用空间容量为K的数组实现请编写代码实现该函数功能。

    提示由于要求仅采用空间容量为K的数组实现因此在输出K阶斐波那契序列过程中需要删除或插入表中的元素。由于插入在表的一端进行删除在表的另一端进行因此采用顺序循环队列实现。在算法执行结束时留在循环队列中的元素应是所求K阶斐波那契序列中的最后K项f(n-k+1),…,fn。