Advertisement
bero_0401

Stack - Queue

Aug 19th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | Source Code | 0 0
  1. using System.Collections;
  2.  
  3. namespace CsharpStudy
  4. {
  5.     /*
  6.      * [ Stack : LIFO]
  7.      * [ Queue : FIFO]
  8.      */
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var st = new Stack<int>();
  14.             st.Push(1);
  15.             st.Push(2);
  16.             st.Push(3);
  17.             Console.WriteLine("Stack");
  18.             Console.WriteLine(st.Pop());
  19.             Console.WriteLine(st.Peek());
  20.                
  21.  
  22.             var qu = new Queue<int>();
  23.             qu.Enqueue(1);
  24.             qu.Enqueue(2);
  25.             qu.Enqueue(3);
  26.             Console.WriteLine("Queue");
  27.             Console.WriteLine(qu.Peek());
  28.             Console.WriteLine(qu.Dequeue());
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement