问题 B: 链表的操作

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:286 通过:175

题目描述

完成链表操作。

#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;
}

输入格式

无输入

输出格式

创建单链表L
单链表L:1 2 3 4 5 6
长度:6
第3个元素:3
元素1是第1个元素
删除第4个元素
单链表L:1 2 111 3 5 6
销毁单链表L