Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- last in first out -> Stack
- first in first out -> Queue
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void kiirat2(Queue<int> s)
- {
- foreach (int x in s)
- {
- Console.Write("{0} ", x);
- }
- }
- static void kiirat(Stack<int> s)
- {
- foreach(int x in s)
- {
- Console.Write("{0} ", x);
- }
- }
- static void Main(string[] args)
- {
- Stack<int> stack = new Stack<int>();
- Queue<int> queue = new Queue<int>();
- stack.Push(13);
- stack.Push(16);
- stack.Push(19);
- stack.Push(25);
- stack.Push(26);
- stack.Push(48);
- stack.Push(78);
- stack.Push(794);
- kiirat(stack);
- Console.WriteLine();
- int a = stack.Pop();
- kiirat(stack);
- Console.WriteLine();
- int b = stack.Peek();
- Console.WriteLine(b);
- queue.Enqueue(14);
- queue.Enqueue(16);
- queue.Enqueue(17);
- queue.Enqueue(18);
- queue.Enqueue(19);
- kiirat2(queue);
- Console.WriteLine();
- queue.Dequeue();
- kiirat2(queue);
- int c = queue.Peek();
- Console.WriteLine();
- Console.WriteLine(c);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement