Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _09092019
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stack zasobnik = new Stack();
- zasobnik.Push('c');
- zasobnik.Push('b');
- zasobnik.Push('f');
- zasobnik.PrintStack();
- zasobnik.Pop();
- Console.WriteLine("pryc");
- zasobnik.PrintStack();
- zasobnik.Peek();
- Console.WriteLine("zustan");
- zasobnik.PrintStack();
- Console.Read();
- }
- }
- class Stack
- {
- char[] zasobnik = new char[10];
- int d = -1;
- public void Push(char c) => zasobnik[++d] = c;
- public void Pop()
- {
- zasobnik.Reverse();
- Console.WriteLine(zasobnik[0]);
- List<char> list = new List<char>(zasobnik);
- list.RemoveAt(0);
- zasobnik = list.ToArray();
- zasobnik.Reverse();
- }
- public void Peek()
- {
- zasobnik.Reverse();
- Console.WriteLine(zasobnik[0]);
- }
- public void IsEmpty()
- {
- bool prazdne = zasobnik.Length == 0;
- }
- public void PrintStack()
- {
- int i;
- for ( i = 0; i < zasobnik.Length; i++)
- {
- Console.WriteLine(zasobnik[i]);
- }
- i = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement