当前位置: 首页 > news >正文

关于申请网站建设经费的报告电子商务网站建设与管理试题及答案

关于申请网站建设经费的报告,电子商务网站建设与管理试题及答案,wordpress淘宝客 采集器,哪些网站容易做线性表的实现方式 顺序表 顺序表是一种线性表的实现方式,它是用一组地址连续的存储单元依次存储线性表中的数据元素,使得逻辑上相邻的元素在物理上也相邻⁴。顺序表可以用数组来实现,它的优点是可以快速定位第几个元素,但是缺点…

线性表的实现方式

顺序表

顺序表是一种线性表的实现方式,它是用一组地址连续的存储单元依次存储线性表中的数据元素,使得逻辑上相邻的元素在物理上也相邻²³⁴。顺序表可以用数组来实现,它的优点是可以快速定位第几个元素,但是缺点是需要预先分配固定大小的空间,插入和删除操作需要移动大量元素¹⁵。顺序表在使用前需要初始化,初始化时需要确定起始位置、存储容量和长度

源: 2023/3/6(1) 数据结构与算法——顺序表的实现及原理 - 索智源 - 博客园. https://www.cnblogs.com/CooCoChoco/p/13150200.html 访问时间 2023/3/6.
(2) 顺序表_百度百科. https://baike.baidu.com/item/%E9%A1%BA%E5%BA%8F%E8%A1%A8/9664274 访问时间 2023/3/6.
(3) 顺序表详解(C语言版)_c语言顺序表_红心火柴的博客-CSDN博客. https://blog.csdn.net/qq_44075108/article/details/108837950 访问时间 2023/3/6.
(4) 数据结构与算法——顺序表的实现及原理 - 索智源 - 博客园. https://www.cnblogs.com/CooCoChoco/p/13150200.html 访问时间 2023/3/6.
(5) 【数据结构入门】顺序表(SeqList)详解(初始化、增、删、查、改)_CodeWinter的博客-CSDN博客. https://blog.csdn.net/weixin_48025315/article/details/119778068 访问时间 2023/3/6.

练习

自定义一个IList

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace _01_LinearList
{interface IListDS<T>{int GetLength();void Clear();bool IsEmpty();void Add(T item);void Insert(T item, int index);T Delete(int index);T this[int index] { get; }//取表的元素T GetEle(int index);//定义一个索引器,获取元素int Locate(T value);//按值查找}
}

定义SeqList实现IList

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace _01_LinearList
{class SeqList<T> : IListDS<T>{private T[] data;//用来存储数据private int count = 0;//表示存了多少个数据public T this[int index] =>GetEle(index);public SeqList(int size)//size就是最大容量{data = new T[size];count = 0;}public SeqList():this(10)//默认构造函数容量是10{}/// <summary>/// 添加值/// </summary>/// <param name="item"></param>public void Add(T item){if (count==data.Length)//当前数组已经存满{Console.WriteLine("当前顺序表已经存满,不允许再存入");}else{data[count] = item;count++;}}/// <summary>/// 清空/// </summary>public void Clear(){count = 0;}/// <summary>/// 删除元素/// </summary>/// <param name="index"></param>/// <returns></returns>public T Delete(int index){T temp = data[index];for (int i = index+1   ; i < count; i++){data[i - 1] = data[i];}count--;return temp;}/// <summary>/// 取元素/// </summary>/// <param name="index"></param>/// <returns></returns>public T GetEle(int index){if (index>=0&&index<=count-1)//索引存在{return data[index];}else{Console.WriteLine("索引不存在");return default(T);            }}/// <summary>/// 取得数据的个数/// </summary>/// <returns></returns>public int GetLength(){return count;}/// <summary>/// 插入元素/// </summary>/// <param name="item"></param>/// <param name="index"></param>public void Insert(T item, int index){for (int i = count-1 ; i >= index; i--){data[i + 1] = data[i];}data[index] = item;count++;}public bool IsEmpty(){return count == 0;}/// <summary>/// 按值查找/// </summary>/// <param name="value"></param>/// <returns></returns>public int Locate(T value){for (int i = 0; i < count; i++){if (data[i].Equals(value)){return i;}}return -1;}}
}

SeqList类(实现IListDS)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace _01_LinearList
{class SeqList<T> : IListDS<T>{private T[] data;//用来存储数据private int count = 0;//表示存了多少个数据public T this[int index] =>GetEle(index);public SeqList(int size)//size就是最大容量{data = new T[size];count = 0;}public SeqList():this(10)//默认构造函数容量是10{}/// <summary>/// 添加值/// </summary>/// <param name="item"></param>public void Add(T item){if (count==data.Length)//当前数组已经存满{Console.WriteLine("当前顺序表已经存满,不允许再存入");}else{data[count] = item;count++;}}/// <summary>/// 清空/// </summary>public void Clear(){count = 0;}/// <summary>/// 删除元素/// </summary>/// <param name="index"></param>/// <returns></returns>public T Delete(int index){T temp = data[index];for (int i = index+1   ; i < count; i++){data[i - 1] = data[i];}count--;return temp;}/// <summary>/// 取元素/// </summary>/// <param name="index"></param>/// <returns></returns>public T GetEle(int index){if (index>=0&&index<=count-1)//索引存在{return data[index];}else{Console.WriteLine("索引不存在");return default(T);            }}/// <summary>/// 取得数据的个数/// </summary>/// <returns></returns>public int GetLength(){return count;}/// <summary>/// 插入元素/// </summary>/// <param name="item"></param>/// <param name="index"></param>public void Insert(T item, int index){for (int i = count-1 ; i >= index; i--){data[i + 1] = data[i];}data[index] = item;count++;}public bool IsEmpty(){return count == 0;}/// <summary>/// 按值查找/// </summary>/// <param name="value"></param>/// <returns></returns>public int Locate(T value){for (int i = 0; i < count; i++){if (data[i].Equals(value)){return i;}}return -1;}}
}

http://www.yayakq.cn/news/818333/

相关文章:

  • 怎么区分营销型和展示型的网站西安火车站网站建设
  • 网匠网站建设有限公司我的qq中心网页版
  • 平凉市网站建设制作敬请期待英语
  • 二环建设部网站网站次年续费
  • 网站建设后期怎样维护群晖wordpress默认地址
  • 石家庄公司网站如何制作爱的网站歌曲
  • 什么做书籍的网站好seo网络营销公司
  • 专题网站可以做什么烟台网站制作公司
  • 石家庄住房和城乡建设厅网站wordpress 图片灯箱
  • 广州建设官方网站网站 数据报表如何做
  • 手机销售网站源码门户网站建站
  • 番禺做网站哪家强seo推广平台
  • 比较好的做简历的网站网站建设 服务范围
  • 免费微网站开发wordpress带轮播企业站主题
  • 杭州市建设住房保障局网站网站内容搜索
  • 网站开发时间一般是网站宣传搭建
  • wordpress不显示头像黑帽seo工具
  • 文昌网站建设 myvodo电脑做网站怎么解析域名
  • 中国建设积分商城网站工作计划怎么写
  • 网站信息架构免费行情网站大全搜狐网
  • 网站建设中左对齐哪一个网站做专栏作家好点
  • 博客类网站源码公司接到网站中文域名到期
  • 优惠券网站怎么做代理网站开发的难点
  • 购物网站需求分析58创业加盟网
  • 嘉兴公司网站建设北京垡头网站建设公司
  • 互联网网站开发的未来方向威海网站开发制作
  • 微网站怎么做的好网络营销外包服务商
  • 做网站要什么知识浏览器下载视频
  • 淘宝怎么做网站wordpress 子主题 样式
  • 连云港市网站平台口碑营销策略有哪些