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

深圳摇号申请网站DW怎么做电商网站

深圳摇号申请网站,DW怎么做电商网站,杭州网站定制,最好的设计师平台网站什么是栈 栈和队列是非常重要的两种数据结构,在软件设计中应用很多。栈和队列也是线性结构,线性表、栈和队列这三种数据结构的数据元素以及数据元素间的逻辑关系完全相同,差别是线性表的操作不受限制,而栈和队列的操作受到眼制。栈的操作只能在表的一端进行,队列的插入操作在表… 什么是栈 栈和队列是非常重要的两种数据结构,在软件设计中应用很多。栈和队列也是线性结构,线性表、栈和队列这三种数据结构的数据元素以及数据元素间的逻辑关系完全相同,差别是线性表的操作不受限制,而栈和队列的操作受到眼制。栈的操作只能在表的一端进行,队列的插入操作在表的一端进行而其它操作在表的另一端进行,所以,把栈和队列称为操作受限的线性表。 BCL中的栈 使用原本有的栈 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; ​ namespace 栈 {internal class Program{static void Main(string[] args){Stackchar stack new Stackchar();stack.Push(a);stack.Push(b);stack.Push(c);//栈顶数据Console.WriteLine(push a b c之后的数据个数为 stack.Count);char temp stack.Pop();//去的栈顶的数据并把栈顶的数据删除Console.WriteLine(pop 之后的数据是temp);Console.WriteLine(pop 之后栈中数据的个数stack.Count);char temp2 stack.Peek();//取出栈顶数据不删除Console.WriteLine(peek 之后栈中数据的个数 stack.Count);stack.Clear();Console.WriteLine(clear之后栈中数据的个数 stack.Count);Console.WriteLine(空栈的时候去的栈顶的值为stack.Peek());//出现异常//空栈的时候不要进行peek和pop操作否则会出现异常Console.ReadKey();}} } ​ 实现顺序栈 自定义顺序栈 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; ​ namespace 栈 {internal interface IStackDST{int Count { get; }//get data numberint Getlenth();bool IsEmpty();void Clear();void Push(T item);T Pop();T Peek(); ​} } ​ ​ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; ​ namespace 栈 {internal class SeqStackT : IStackDST{private T[] data; ​private int top; ​public SeqStack(int size){data new T[size];top -1;}public SeqStack():this(10){ ​}public int Count{get { return top 1; }} ​public void Clear(){top -1;} ​public int Getlenth(){return Count;} ​public bool IsEmpty(){return Count 0;} ​public T Peek(){return data[top];} ​public T Pop(){T temp data[top];top--;return temp;} ​public void Push(T item){data[top1] item;top;}} } ​ ​ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; ​ namespace 栈 {internal class Program{static void Main(string[] args){SeqStackchar stack new SeqStackchar();stack.Push(a);stack.Push(b);stack.Push(c);//栈顶数据Console.WriteLine(push a b c之后的数据个数为 stack.Count);char temp stack.Pop();//去的栈顶的数据并把栈顶的数据删除Console.WriteLine(pop 之后的数据是temp);Console.WriteLine(pop 之后栈中数据的个数stack.Count);char temp2 stack.Peek();//取出栈顶数据不删除Console.WriteLine(peek 之后栈中数据的个数 stack.Count);stack.Clear();Console.WriteLine(clear之后栈中数据的个数 stack.Count);Console.WriteLine(空栈的时候去的栈顶的值为stack.Peek());//出现异常//空栈的时候不要进行peek和pop操作否则会出现异常Console.ReadKey();}} } ​ 链栈 public class NodeT {public T Data { get; set; }public NodeT Next { get; set; } ​public Node(T data){Data data;Next null;} } ​ public class LinkedStackT {private NodeT top; ​public LinkedStack(){top null;} ​// 判断栈是否为空public bool IsEmpty(){return top null;} ​// 入栈操作public void Push(T data){NodeT newNode new NodeT(data);newNode.Next top;top newNode;} ​// 出栈操作public T Pop(){if (IsEmpty()){throw new InvalidOperationException(栈为空无法执行出栈操作。);}T data top.Data;top top.Next;return data;} ​// 查看栈顶元素public T Peek(){if (IsEmpty()){throw new InvalidOperationException(栈为空无法查看栈顶元素。);}return top.Data;} ​// 清空栈public void Clear(){top null;} } ​ // 使用示例 public class Program {public static void Main(string[] args){LinkedStackint stack new LinkedStackint(); ​stack.Push(1);stack.Push(2);stack.Push(3); ​Console.WriteLine(stack.Pop());  // 输出 3Console.WriteLine(stack.Peek()); // 输出 2 ​stack.Push(4);Console.WriteLine(stack.Pop());  // 输出 4 ​while (!stack.IsEmpty()){Console.WriteLine(stack.Pop());}} } 什么是队列 队列Queue是一种遵循先进先出FIFOFirst In First Out原则的抽象数据类型。在队列中元素的添加入队总是在一端进行称为队尾Rear而元素的移除出队总是在另一端进行称为队首Front。 顺序队列 using System; ​ public class SequentialQueueT {private T[] queue;private int head;private int tail;private int count;private int capacity; ​public SequentialQueue(int capacity){this.capacity capacity;queue new T[capacity];head 0;tail 0;count 0;} ​// 判断队列是否为空public bool IsEmpty(){return count 0;} ​// 判断队列是否已满public bool IsFull(){return count capacity;} ​// 入队操作public void Enqueue(T item){if (IsFull()){throw new InvalidOperationException(队列已满无法入队。);}queue[tail] item;tail (tail 1) % capacity;count;} ​// 出队操作public T Dequeue(){if (IsEmpty()){throw new InvalidOperationException(队列为空无法出队。);}T item queue[head];queue[head] default(T); // 清除队首元素head (head 1) % capacity;count--;return item;} ​// 查看队首元素public T Peek(){if (IsEmpty()){throw new InvalidOperationException(队列为空无法查看队首元素。);}return queue[head];} ​// 获取队列的当前元素数量public int Count(){return count;} } ​ // 使用示例 public class Program {public static void Main(string[] args){SequentialQueueint queue new SequentialQueueint(5); ​queue.Enqueue(1);queue.Enqueue(2);queue.Enqueue(3); ​Console.WriteLine(queue.Dequeue());  // 输出 1Console.WriteLine(queue.Peek());     // 输出 2 ​queue.Enqueue(4);queue.Enqueue(5);queue.Enqueue(6); ​while (!queue.IsEmpty()){Console.WriteLine(queue.Dequeue());}} } 链队列
http://www.zqtcl.cn/news/627838/

相关文章:

  • 如何开公司注册需要多少钱东莞网站推广优化网上推广公司
  • 新闻门户网站制作教育培训网站开发
  • 网站建设公司哪个好一点最近一周的热点新闻
  • 做最优秀的自己的视频网站佛山搜索引擎优化
  • 六盘水市网站建设免费封面设计在线制作生成
  • 北京快速建站制作公司wordpress wpoptions
  • iis如何建立网站门源县住房和城乡建设局网站
  • 装修素材图片都从什么网站找铁门关网站建设
  • 网站服务器环境不支持mysql数据库免费商标图案logo
  • 以什么主题做网站好wordpress怎么设置404
  • 为什么手机进网站乱码网络营销工具的特点
  • DW怎么做网站下拉菜单网站建设外包网站
  • 手机做兼职的网站设计公司注册记账代理公司
  • 如何在vs做网站建筑工程电影网
  • 甘肃网站开发网站建设自己在家接单
  • 龙岗网站制作资讯福田区龙岗区发布通告
  • 百度如何快速收录网站嘉兴手机建站模板
  • 服务注册中心有哪些给你一个网站你如何做优化
  • 我做网站如何分流客户openwrt 做视频网站
  • 徐州微信网站建设建设工程项目
  • 便宜网站建设公司envision wordpress
  • 网站怎么做百度快照logo网站域名做固定资产怎么处理
  • 2003 iis网站发布工会网站建设管理工作总结
  • 商城网站大概多少钱长沙网站设计公司推荐
  • 海南省交通建设局网站首页做网站开发一般用什么语言
  • 个人备案网站沭阳哪里可以做网站
  • 环球资源网站什么时候做的搜索引擎优化名词解释
  • 名者观看网站做商城网站还要服务器
  • 网站建设课程考核方案广州 天河网站设计
  • 写作网站哪个比较赚钱小红书推广运营