完成链表操作。
#include <iostream>
using namespace std;
struct LinkList //循环单链表结点类型
{ int data; //存放数据元素
LinkList *next; //指向下一个结点的域
}*head;
//---------------单链表的基本运算算法-----------------------------
void init() //创建一个空循环单链表
{ }
void Destory() //销毁循环单链表
{ }
void CreateListF(int a[],int n) //头插法建立循环单链表
{ }
void CreateListR(int a[],int n) //尾插法建立循环单链表
{ }
void DispList() //输出循环单链表所有结点值
{ }
int ListLength() //求循环单链表数据结点个数
{ }
bool GetElem(int i, int &e) //求循环单链表中某个数据元素值
{ }
int LocateElem(int e) //按元素值查找
{ }
bool ListInsert(int i, int e) //插入数据元素
{ }
bool ListDelete(int i) //删除数据元素
{ }
int main()
{
int i,e;
int a[]={1,2,3,4,5,6};
init();
cout << "创建单链表L" << endl;
CreateListR(a,6);
cout << "单链表L:"; DispList();
cout << "长度:" << ListLength() << endl;
i=3; GetElem(i,e);
cout << "第" << i << "个元素:" << e << endl;
e=1;
cout << "元素" << e << "是第" <<LocateElem(e) << "个元素\n";
i=4; cout << "删除第" << i << "个元素\n";
ListDelete(i);
ListInsert(3,111); //插入元素2
cout << "单链表L:";DispList();
cout << "销毁单链表L" << endl;
return 0;
}
无输入