一.实验目的
巩固线性表的数据结构的存储方法和相关操作,学会针对具体应用,使用线性表的相关知识来解决具体问题。
二..实验内容
建立一个由n个学生成绩的顺序表,n的大小由自己确定,每一个学生的成绩信息由自己确定,
实现数据的对表进行插入、删除、查找等操作。分别输出结果。
(用循环链表来实现)。
三..源代码
#include<iomanip>
template<class T>
struct Node
{
T data;
Node<T> *next;
};
template<class T>
class CircleList
{
private:
int length; //链表长度
Node<T> *first; //定义头指针
public:
CircleList(); //默认构造函数
CircleList(T a[], int n); //定义长度为N的有参构造函数
~CircleList();//析构函数
int GetLength(); //求链表长度
T Get(int i); //按位查找
int Locate(T x); //按值查找
bool Insert(int i, T x); //插入操作
T Delete(int i); //删除操作
void PrintList(); //遍历操作
};
template<class T>
CircleList<T>::CircleList()
{
first = new Node<T>;
first->next = first;
length = 0;
}
template<class T>
CircleList<T>::CircleList