zoukankan      html  css  js  c++  java
  • Queue和Stack的学习代码

    using System;
    using System.Collections;
    using System.Windows.Forms;

    namespace Lightsoftware
    {
     #region <summary>
     /// <summary>
     ///
     /// </summary>
     #endregion
     public class MyClass: Object
     {
      public static void Main(String[] args)
      {
       TestQueue();
       TestStack();
      }

      private static void TestQueue()
      {
       Queue queue = new Queue();   
       queue.Enqueue(5);
       queue.Enqueue(7);
       queue.Enqueue(9);

       Int32 count = queue.Count;

       //output 5, 7, 9
       for (Int32 index = 0; index < count; ++index)
       {
        MessageBox.Show(((Int32)queue.Dequeue()).ToString());
       }
      }

      public static void TestStack()
      {
       Stack stack = new Stack();
       stack.Push(5);
       stack.Push(7);
       stack.Push(9);

       Int32 count = stack.Count;
       
       //output 9, 7, 5
       for (Int32 index = 0; index < count; ++index)
       {
        MessageBox.Show(((Int32)stack.Pop()).ToString());
       }
      }
     }
    }

  • 相关阅读:
    【安装软件的点点滴滴】
    【自然语言处理】LDA
    【sklearn】数据预处理 sklearn.preprocessing
    【sklearn】中文文档
    【MySql】update用法
    DotNet Core
    ASP.NET MVC
    ADO.NET
    RESTful API
    C#
  • 原文地址:https://www.cnblogs.com/light/p/35918.html
Copyright © 2011-2022 走看看