




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
8576顺序线性表的基本操作时间限制:1000MS 内存限制:1000K提交次数:1714 通过次数:300题型: 编程题语言: 无限制Description编写算法,创建初始化容量为LIST_INIT_SIZE的顺序表T,并实现插入、删除、遍历操作。本题目给出部分代码,请补全内容。#include#include#define OK 1 #define ERROR 0#define LIST_INIT_SIZE 100#define LISTINCREMENT 10#define ElemType inttypedef structint *elem;int length;int listsize;SqList;int InitList_Sq(SqList &L)/ 算法2.3,构造一个空的线性表L,该线性表预定义大小为LIST_INIT_SIZE/ 请补全代码int Load_Sq(SqList &L)/ 输出顺序表中的所有元素int i;if(_) printf(The List is empty!); / 请填空elseprintf(The List is: );for(_) printf(%d ,_); / 请填空printf(n);return OK;int ListInsert_Sq(SqList &L,int i,int e)/ 算法2.4,在顺序线性表L中第i个位置之前插入新的元素e/ i的合法值为1iL.length +1/ 请补全代码int ListDelete_Sq(SqList &L,int i, int &e)/ 算法2.5,在顺序线性表L中删除第i个位置的元素,并用e返回其值/ i的合法值为1iL.length/ 请补全代码int main()SqList T;int a, i;ElemType e, x;if(_) / 判断顺序表是否创建成功printf(A Sequence List Has Created.n);while(1)printf(1:Insert elementn2:Delete elementn3:Load all elementsn0:ExitnPlease choose:n);scanf(%d,&a);switch(a)case 1: scanf(%d%d,&i,&x);if(_) printf(Insert Error!n); / 判断i值是否合法,请填空else printf(The Element %d is Successfully Inserted!n, x); break;case 2: scanf(%d,&i);if(_) printf(Delete Error!n); / 判断i值是否合法,请填空else printf(The Element %d is Successfully Deleted!n, e);break;case 3: Load_Sq(T);break;case 0: return 1;Input测试样例格式说明:根据菜单操作:1、输入1,表示要实现插入操作,紧跟着要输入插入的位置和元素,用空格分开2、输入2,表示要实现删除操作,紧跟着要输入删除的位置3、输入3,表示要输出顺序表的所有元素4、输入0,表示程序结束Sample Input11 211 32130Sample OutputA Sequence List Has Created.1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The Element 2 is Successfully Inserted!1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The Element 3 is Successfully Inserted!1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The Element 3 is Successfully Deleted!1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The List is: 2 1:Insert element2:Delete element3:Load all elements0:Exit8577合并顺序表时间限制:1000MS 内存限制:1000K提交次数:1007 通过次数:288题型: 编程题语言: 无限制Description编写算法,将两个非递减有序顺序表A和B合并成一个新的非递减有序顺序表C。本题不提供代码,请同学们独立完成,所需子函数参考前面完成的内容。Input第一行:顺序表A的元素个数第二行:顺序表A的各元素(非递减),用空格分开第三行:顺序表B的元素个数第四行:顺序表B的各元素(非递减),用空格分开Output第一行:顺序表A的元素列表第二行:顺序表B的元素列表第三行:合并后顺序表C的元素列表Sample Input51 3 5 7 952 4 6 8 10Sample OutputList A:1 3 5 7 9 List B:2 4 6 8 10 List C:1 2 3 4 5 6 7 8 9 10 8578顺序表逆置时间限制:1000MS 内存限制:1000K提交次数:655 通过次数:285题型: 编程题语言: 无限制Description设有一顺序表A=(a0,a1,., ai,.an-1),其逆顺序表定义为A=( an-1,., ai,.,a1, a0)。设计一个算法,将顺序表逆置,要求顺序表仍占用原顺序表的空间。本题不提供代码,请同学们独立完成,所需子函数参考前面完成的内容。Input第一行:输入顺序表的元素个数第二行:输入顺序表的各元素,用空格分开Output第一行:逆置前的顺序表元素列表第二行:逆置后的顺序表元素列表Sample Input101 2 3 4 5 6 7 8 9 10Sample OutputThe List is:1 2 3 4 5 6 7 8 9 10 The turned List is:10 9 8 7 6 5 4 3 2 18579链式线性表的基本操作时间限制:1000MS 内存限制:1000K提交次数:762 通过次数:243题型: 编程题语言: 无限制Description编写算法,创建一个含有n个元素的带头结点的单链表L并实现插入、删除、遍历操作。本题目提供部分代码,请补全内容。#include#include#define ERROR 0#define OK 1 #define ElemType inttypedef struct LNode int data; struct LNode *next;LNode,*LinkList;int CreateLink_L(LinkList &L,int n)/ 创建含有n个元素的单链表 LinkList p,q; int i; ElemType e; L = (LinkList)malloc(sizeof(LNode); L-next = NULL; / 先建立一个带头结点的单链表 q = (LinkList)malloc(sizeof(LNode); q = L; for (i=0; inext; if(_)printf(The List is empty!); / 请填空 else printf(The LinkList is:); while(_) / 请填空 printf(%d ,p-data); _ / 请填空 printf(n); return OK;int LinkInsert_L(LinkList &L,int i,ElemType e)/ 算法2.9/ 在带头结点的单链线性表L中第i个位置之前插入元素e/ 请补全代码int LinkDelete_L(LinkList &L,int i, ElemType &e)/ 算法2.10/ 在带头结点的单链线性表L中,删除第i个元素,并用e返回其值/ 请补全代码int main() LinkList T; int a,n,i; ElemType x, e; printf(Please input the init size of the linklist:n); scanf(%d,&n); printf(Please input the %d element of the linklist:n, n); if(_) / 判断链表是否创建成功,请填空 printf(A Link List Has Created.n); LoadLink_L(T); while(1)printf(1:Insert elementn2:Delete elementn3:Load all elementsn0:ExitnPlease choose:n);scanf(%d,&a);switch(a)case 1: scanf(%d%d,&i,&x); if(_) printf(Insert Error!n); / 判断i值是否合法,请填空 else printf(The Element %d is Successfully Inserted!n, x); break;case 2: scanf(%d,&i); if(_) printf(Delete Error!n); / 判断i值是否合法,请填空 else printf(The Element %d is Successfully Deleted!n, e); break;case 3: LoadLink_L(T); break;case 0: return 1;Input测试样例格式说明:根据菜单操作:1、输入1,表示要实现插入操作,紧跟着要输入插入的位置和元素,用空格分开2、输入2,表示要实现删除操作,紧跟着要输入删除的位置3、输入3,表示要输出顺序表的所有元素4、输入0,表示程序结束Sample Input33 6 9314 122130Sample OutputPlease input the init size of the linklist:Please input the 3 element of the linklist:A Link List Has Created.The LinkList is:3 6 9 1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The LinkList is:3 6 9 1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The Element 12 is Successfully Inserted!1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The Element 3 is Successfully Deleted!1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:The LinkList is:6 9 12 1:Insert element2:Delete element3:Load all elements0:ExitPlease choose:8580合并链表时间限制:1000MS 内存限制:1000K提交次数:471 通过次数:257题型: 编程题语言: 无限制Description设计一个算法将两个非递减有序链表A和B合并成一个新的非递减有序链表C。本题不提供代码,请同学们独立完成,所需子函数参考之前完成的内容。Input第一行:单链表A的元素个数第二行:单链表A的各元素(非递减),用空格分开第三行:单链表B的元素个数第四行:单链表B的各元素(非递减),用空格分开Output第一行:单链表A的元素列表第二行:单链表B的元素列表第三行:合并后单链表C的元素列表Sample Input612 24 45 62 84 96415 31 75 86Sample OutputList A:12 24 45 62 84 96 List B:15 31 75 86 List C:12 15 24 31 45 62 75 84 86 968581线性链表逆置时间限制:1000MS 内存限制:1000K提交次数:423 通过次数:254题型: 编程题语言: 无限制Description设有一线性表A=(a0,a1,., ai,.an-1),其逆线性表定义为A=( an-1,.,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 信托行业资产证券化方案
- 北京市门头沟区2026届化学高二上期末达标检测试题含答案
- 福建省漳州市华安县第一中学2026届化学高一第一学期期末统考试题含解析
- 水产养殖疾病防控操作方案
- 建筑装饰与装修技术作业指导书
- 能源管理与环保技术作业指导书
- 二年级道法实践活动计划
- 江西省2026届高三化学第一学期期中联考试题含解析
- 2025年大数据开发必-备知识点及考试答案
- 广告创意设计指南
- 投标造价委托协议书范本
- 六年级下册数学竞赛试题-抽屉原理习题(含答案)
- 2025年军队专业技能岗位文职人员招聘考试(炊事员)历年参考题库含答案详解(5套)
- 高警示药品风险管理
- 医院重症护理技能竞赛理论考试(CRRT)试题及答案
- 2025年新乡事业单位招聘考试笔试试卷(附答案)
- 2025秋人教版八年级上册历史全册重点知识点早背晚默
- 2025年标准货物出口合同范本(中英文版)
- 2025年新钢铁安全员考试题库及答案
- 2025版电子购销合同模板
- 护理中医小讲课课件
评论
0/150
提交评论